James Britt wrote:
> Suppose secret_code=(x) checks that the given value meets some criteria
> (say, is a positive int), and if not, uses the value 0.  I might want
> the method to then return  a valid value, not simply what was passed in.

If the setter is called in an assignment context, the assignment will 
always return the rhs regardless of what the setter returns.  This is 
for compatibility as Ezra pointed out.

If you do:
a = b = c = 3
what's the value of a?  You would expect it to be 3.

What about:
a = b.bar = c = 3
What is a now?  Again, wouldn't you still be hoping it would be 3?

Assignment is a syntactic construct.  "b.bar = 3" is not a method call, 
it's an assignment.  Part of evaluating that assignment involves 
invoking a method, but, by definition, assignment returns the rhs, so 
whatever happens with any method so invoked, its value is lost.
-- 
Posted via http://www.ruby-forum.com/.