Created
February 5, 2015 13:57
-
-
Save shigemk2/8cf6351e482e3a50804a 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 names = Array("chris", "ed", "maurice") | |
println(names(0)) | |
val capNames = for (e <- names) yield e.capitalize | |
println(capNames(0)) | |
val lengths = for (e <- names) yield { | |
// imagine that this required multiple lines of code | |
e.length | |
} | |
println(lengths(0)) | |
var fruits = scala.collection.mutable.ArrayBuffer[String]() | |
fruits += "apple" | |
fruits += "banana" | |
fruits += "orange" | |
println(fruits(0)) | |
val out = for (e <- fruits) yield e.toUpperCase | |
println(out(0)) | |
var fruits2 = "apple" :: "banana" :: "orange" :: Nil | |
println(fruits2(0)) | |
var out2 = for (e <- fruits2) yield e.toUpperCase | |
println(out2(0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment