Last active
December 31, 2023 17:48
-
-
Save k41n3w/37b1e9ecfdd3ca94847d28d808072e79 to your computer and use it in GitHub Desktop.
Código 6 - 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
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