Consider the following code:
class Student
attr_accessor :age, :gender, :school
def explicit_school_setter
@school = "Some School"
end
end
bob = Student.new
bob.age = 16
bob.gender = :male
bob.instance_eval { school = :bvb } # ? Why is this not invoking the setter?
bob.age # => 16
bob.gender # => :male
bob.school # => nil
bob.instance_eval { explicit_school_setter }
bob.school # => "Some School"
bob.school = "Another School"
bob.school # => "Another School"
Why is the setter not working in the instance_eval
block?