Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Scala Type Inference

Name: Anonymous 2012-10-27 0:24

Does anyone know the details why?


def map[T, U](a: List[T], f: (T) => U): List[U] =
  for (e <- a) yield f(e)
 
def map0[T, U](a: List[T])(f: (T) => U): List[U] =
  for (e <- a) yield f(e)
 
// type parameter necessary
map(List(1,2,3), (x: Int) => x.toString)
 
// type parameter not necessary
map0(List(1,2,3))(_.toString)

Name: Anonymous 2012-10-27 7:01

>>2

Ya I just played around with Haskell and Ocaml. They're type inference is on a another level.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List