Scala - A Simple Match Code Example

The code for A Simple Match

val bools_value = List(true, false)
for (bool <- bools_value) {
 bool match {
 case true => println("It is true.")
 case false => println("It is false.")
 case _ => println("Other than true and false")
 }
}

/*
Output:
It is true.
It is false.
*/
Code by IncludeHelp, on August 7, 2022 17:39

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.