From: Mike Ryan Date: 2009-06-29T08:48:24+09:00 Subject: [ruby-core:24073] [Bug #1698] Incorrect return value for writer methods. Bug #1698: Incorrect return value for writer methods. http://redmine.ruby-lang.org/issues/show/1698 Author: Mike Ryan Status: Open, Priority: Normal ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9] I found the following behavior this past week and found it a bit odd. irb(main):001:0> class Foo irb(main):002:1> def bar=(bla) irb(main):003:2> @bar = bla * 2 irb(main):004:2> end irb(main):005:1> def bar irb(main):006:2> @bar irb(main):007:2> end irb(main):008:1> end => nil irb(main):009:0> a = Foo.new => # irb(main):010:0> a.bar = 10 => 10 irb(main):011:0> a.bar => 20 irb(main):012:0> a.send(:bar=, 7) => 14 irb(main):013:0> a.bar => 14 irb(main):014:0> a.bar=(3) => 3 irb(main):015:0> a.bar => 6 You'll see that line 10 returns the value that we are passing to the bar=(bla) method, but not the actual return value. Not certain if it was because I wasn't explicitly returning a value, I found that this did not matter: irb(main):001:0> class Foo irb(main):002:1> def strange=(bla) irb(main):003:2> return "correct return value" irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> a = Foo.new => # irb(main):007:0> a.strange = "this is strange" => "this is strange" irb(main):008:0> a.send(:strange=, "this is also strange") => "correct return value" I see this in both 1.9.1p129 and 1.8.7p72. ---------------------------------------- http://redmine.ruby-lang.org