Last active
October 10, 2023 09:00
-
-
Save rodobarcaaa/1503f0f677777ec5ffbca12f1438b370 to your computer and use it in GitHub Desktop.
Scala If Else
This file contains hidden or 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 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