Created
September 3, 2018 20:06
-
-
Save AmineSagaama/754cf5cedebc77f669111c91b2f6ff99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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