Skip to content

Instantly share code, notes, and snippets.

@k41n3w
Last active December 31, 2023 17:49
Show Gist options
  • Save k41n3w/0b9f9d1f3a164d5cd7e60470a01e589f to your computer and use it in GitHub Desktop.
Save k41n3w/0b9f9d1f3a164d5cd7e60470a01e589f to your computer and use it in GitHub Desktop.
Código 5 - Post de 'Passagem de parâmetros em Ruby"
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