From: Arlen Cuss Date: 2008-02-25T19:51:25+09:00 Subject: Re: Suprising behaviour with "def property=" method ------=_Part_11772_28288834.1203936692559 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, Feb 25, 2008 at 12:03 PM, 7stud -- wrote: > class Dog > def secret_code=(seed) > @secret_code = seed * 10 + 2 > end > end > > d = Dog.new > return_val = (d.secret_code=(3) ) > puts return_val #should this reveal the secret code? > Yes. What would you like it to return? The point is, you're doing d.secret_code = 3 -- you're saying the secret code *is* 3, so actually setting it to something else is a bit misleading, don't you think? class Dog def generate_secret_code(seed) @secret_code = seed * 10 + 2 self end end This has the fun of allowing method chaining; d = Dog.new d.generate_secret_code(3).some_other_method_that_chains.yet_another(some, args) Arlen ------=_Part_11772_28288834.1203936692559--