Skip to content

Instantly share code, notes, and snippets.

@dirkmc
Created December 22, 2011 08:47
Show Gist options
  • Save dirkmc/1509559 to your computer and use it in GitHub Desktop.
Save dirkmc/1509559 to your computer and use it in GitHub Desktop.
Scala List map

Use List.map() to transform a list of elements into another list:

val fruitPics = List("banana.jpg", "orange.jpg", "strawberry.jpg", "apple.jpg")
val fileSizes = fruitPics.map(fruit => new java.io.File(parentDir, fruit).length)
// fileSizes: List(12321423, 643423, 234233, 2342343)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment