Skip to content

Instantly share code, notes, and snippets.

@AmineSagaama
Created September 3, 2018 20:06
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 AmineSagaama/754cf5cedebc77f669111c91b2f6ff99 to your computer and use it in GitHub Desktop.
Save AmineSagaama/754cf5cedebc77f669111c91b2f6ff99 to your computer and use it in GitHub Desktop.
val items = List("A", "B", "C")
//method reference
//Output : A,B,C
items.foreach(println)
//Output : A
items.foreach(item => if ("A".equals(item))
println(item))
//Map and filter
//Output : CX
items.map(s => s + "X")
.filter(x => x.contains("CX"))
.foreach(println)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment