I was trying to see if I could transfer an instance variable's attributes using a simple do
statement.
class Dog
def initialize(name, age)
@name = name
@age = age
end
def bark
puts 'Woof'
puts 'Woof'
puts 'Woof'
end
end
bo = Dog.new do |word|
word.bark
end
Why does it return the class id instead of the function's output?
Dog.new
method isn't even evaluated, so the only thing that this piece of code returns to the console is the identifier of the newDog
instance, initialized bynew
.