0

In Scala collections (e.g. 2.11 or 2.12), where can I find the code that gets executed when an Array is mapped?

i.e.

val a = Array(1,2,3)
val b = a.map(_ * 5)   // <--- here
mitchus
  • 4,677
  • 3
  • 35
  • 70

1 Answers1

3

That would be TraversableLike.

When methods such as map are called on arrays, an implicit conversion to ArrayOps kicks in (e.g. Predef.intArrayOps), which in turn derives these methods from SeqLike / TraversableLike through inheritance.

mitchus
  • 4,677
  • 3
  • 35
  • 70
Sergey
  • 2,880
  • 3
  • 19
  • 29