You can return stuff from a for loop with the "yield" command
def looping() = {
val myList = (1 to 20 by 3)
println(myList)
val list2 = for( i <- myList if i % 2 == 0 ) yield i
println(list2)
}
def looping() = {
val myList = (1 to 20 by 3)
println(myList)
val list2 = for( i <- myList if i % 2 == 0 ) yield i
println(list2)
}
No comments:
Post a Comment