From: Robert Feldt Date: 2001-05-07T23:20:00+09:00 Subject: [ruby-talk:14768] SimpleDelegator assymetry Hi folks, Can someone explain the "assymetry" in the behavior of the code below? /Robert require 'delegate' class STB1; def b; 1; end; end class STB2; def b; 2; end; end class ANB < SimpleDelegator def initialize(o) super(o) end def change(o) __setobj__(o) end end def test(first, second) a1 = ANB.new(first) begin puts a1.b rescue NameError puts "1: Caught error" end a1.change(second) begin puts a1.b rescue NameError puts "2: Caught error" end end test(STB1.new, STB2.new) # Both ok. test(STB1.new, nil) # Ok, error on 2nd call since nil has no b method test(nil, STB2.new) # but why error on 2nd call here? # Or is it just my PoLS feeling that is wrong? # Ps. PoLS = Principle of Least Surprise