Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.