Last active
December 31, 2023 17:49
-
-
Save k41n3w/0b9f9d1f3a164d5cd7e60470a01e589f to your computer and use it in GitHub Desktop.
Código 5 - Post de 'Passagem de parâmetros em Ruby"
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
def greet(options) | |
name = options[:name] | |
age = options[:age] | |
puts "Olá, #{name}! Você tem #{age} anos." | |
end | |
greet({ name: "Ana", age: 35 }) | |
# Retorno: "Olá, Ana! Você tem 35 anos." | |
# greet(name: "Ana", age: 35) Fora da hash também funciona! | |
# greet(name: "Ana") Fora da hash "faltando" valores funciona! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment