Last active
October 10, 2023 09:00
-
-
Save rodobarcaaa/1d36e7f20063a6d139fae0e3a5b70a82 to your computer and use it in GitHub Desktop.
Scala Pattern Matching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object HelloWorldPatternMatching extends App { | |
private val language = "pt" | |
//no hay necesidad de colocar break el rompe donde primero coincida y si no en el default, es decir ' _ ' | |
private val message = language match { | |
case "es" => "¡Hola, mundo!" | |
case "pt" => "¡Olá, mundo!" | |
case _ => "Hello, world!" | |
} | |
println(message) //¡Olá, mundo! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment