The following code:
class A
def foo= foo; puts "b" end
end
A.new.foo=("foo").tap{puts "a"}
prints "a"to "b", which means it tapis called before the setter method foo=. This runs counter to intuition, as I thought the method chain works from left to right. In this example, it appears that the setter method is skipped and runs later. However, it is clear that setter methods are not always executed last in the code. Then, at what point is this foo=, or are setter methods generally executed?
sawa source
share