Skip to content

Instantly share code, notes, and snippets.

@rodobarcaaa
Last active October 10, 2023 09:00
Show Gist options
  • Save rodobarcaaa/1d36e7f20063a6d139fae0e3a5b70a82 to your computer and use it in GitHub Desktop.
Save rodobarcaaa/1d36e7f20063a6d139fae0e3a5b70a82 to your computer and use it in GitHub Desktop.
Scala Pattern Matching
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