Skip to content

Instantly share code, notes, and snippets.

@Moverr
Last active January 4, 2021 19:34
Show Gist options
  • Save Moverr/3980cdf983f00ffa3d90605f89f0b49d to your computer and use it in GitHub Desktop.
Save Moverr/3980cdf983f00ffa3d90605f89f0b49d to your computer and use it in GitHub Desktop.
object loops {
def isEven(number: Int) = number % 2 == 0
def main(args: Array[String]): Unit = {
val list = List(1, 2, 3, 4, 5)
list.foreach(x => if(isEven(x)) println(x) )
//todo multiple levels of itereation
val firstList = List('A', 'B', 'C')
val secondList = List("XA", "yA", "ZA")
firstList.foreach(first => secondList.foreach(second => println(first.toString + second)))
println("Interesting")
}
}
@Moverr
Copy link
Author

Moverr commented Jan 4, 2021

object loops {
def main(args: Array[String]): Unit = {

  val list = List(1, 2, 3)
  list.foreach(x => println(x) )

  println("Interesting")
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment