Skip to content

Instantly share code, notes, and snippets.

@rodobarcaaa
Last active October 10, 2023 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodobarcaaa/1503f0f677777ec5ffbca12f1438b370 to your computer and use it in GitHub Desktop.
Save rodobarcaaa/1503f0f677777ec5ffbca12f1438b370 to your computer and use it in GitHub Desktop.
Scala If Else
object HelloWorldIfElse extends App {
// Podemos ver como vimos antes que si no ponemos tipo scala lo infiere por nosotros
val language = "en"
// podemos notar que si no tiene parámetros la función no necesita paréntesis
def message = {
if (language == "es") "¡Hola, mundo!"
else if (language == "pt") "¡Olá, mundo!"
else "Hello, world!"
}
println(message) //Hello, world!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment