如何从块内更新实例变量?
例如
def initialize_people(people)
people.each do |person|
person = "Bob" if person.nil?
end
end
@first = "Adam"
@second = "Eve"
@third = nil
people = [@first, @second, @third]
initialize_people(people)
puts people
# outputs
# Adam
# Eve
# would like it to output
# Adam
# Eve
# Bob