Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Created January 18, 2012 02:10
Show Gist options
  • Select an option

  • Save diegopacheco/1630375 to your computer and use it in GitHub Desktop.

Select an option

Save diegopacheco/1630375 to your computer and use it in GitHub Desktop.
Lambda in Scala
() => 2 +2 // () => Int = <function0>
(() => 2 + 2)() // 4
List(1,2,3,4,5).map( i => i + 1 ) // List(2, 3, 4, 5, 6)
List(1,2,3,4,5,6,7,8,9,10).filter( n => n >= 7 ) // List(7, 8, 9, 10)
List(1,2,3,4,5,6,7,8,9,10).filter( _ >= 7 ) // List(7, 8, 9, 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment