Scala - Using if expressions in case statements Code Example

The code for Using if expressions in case statements

val count = 11

count match {
    case 1 => println("One")
    case x if x == 2 || x == 3 => println("Two or Three")
    case x if x > 3 => println("Greater than Three")
    case _ => println("Undefined")
}

/*
Output:
Greater than Three
*/
Code by IncludeHelp, on August 8, 2022 02:18

Comments and Discussions!

Load comments ↻






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