Skip to content

Instantly share code, notes, and snippets.

@k41n3w
Last active December 31, 2023 17:48
Show Gist options
  • Save k41n3w/37b1e9ecfdd3ca94847d28d808072e79 to your computer and use it in GitHub Desktop.
Save k41n3w/37b1e9ecfdd3ca94847d28d808072e79 to your computer and use it in GitHub Desktop.
Código 6 - Post de 'Passagem de parâmetros em Ruby"
class Person
attr_accessor: name,: age
def initialize(name, age)
@name = name
@age = age
end
end
def greet(person)
puts "Olá, #{person.name}! Você tem #{person.age} anos."
end
person = Person.new("Carlos", 40)
greet(person)
# Retorno: "Olá, Carlos! Você tem 40 anos."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment