Skip to content

Instantly share code, notes, and snippets.

@joecwu
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joecwu/979b5b096ac03e7f31dc to your computer and use it in GitHub Desktop.
Save joecwu/979b5b096ac03e7f31dc to your computer and use it in GitHub Desktop.
val list=List(1,2,3,4,5)
//list: List[Int] = List(1, 2, 3, 4, 5)
val oddFilter= (x:Int)=>x%2==1
//oddFilter: Int => Boolean = <function1>
list.filter(oddFilter)
//res0: List[Int] = List(1, 3, 5)
list.filter(x=>x%2==1)
//res1: List[Int] = List(1, 3, 5)
list.filter{ x=>
x%2==1
}
//res2: List[Int] = List(1, 3, 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment