otrzymują prosty sekwencja:anonimowych parametry Robocze- ale nie wyraźne te - dla Scala reduceLeft
scala> val a = Seq(1.0,2.0,3.0)
res8: Seq[Double] = List(1.0, 2.0, 3.0)
Dodajmy je!
scala> a.reduceLeft{_ + _}
res6: Double = 6.0
Ale jak być wyraźnym z parametrami? Oto moja próba:
scala> a.reduceLeft{case(b,c) => b+c}
Cóż .. nie .. Mamy niedopasowanie typu:
<console>:9: error: missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type was: (?, Double) => ?
a.reduceLeft{case(b,c) => b+c}
^
<console>:9: error: type mismatch;
found : Any
required: String
a.reduceLeft{case(b,c) => b+c
Ale nawet kiedy dodać w rodzajach wyraźnie to nie działa:
scala> a.reduceLeft{case(b:Double,c:Double) => b+c}
<console>:9: error: missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type was: (?, Double) => ?
a.reduceLeft{case(b:Double,c:Double) => b+c}
Co tu się dzieje?
dzięki. Wkrótce nagrodzę (wygląda na zegar oznaczający 5 minut). – javadba