From: Rick DeNatale Date: 2009-08-27T02:14:54+09:00 Subject: Re: ||= with 1.8 and 1.9 ? On Wed, Aug 26, 2009 at 12:49 PM, 7stud -- wrote: > Rick Denatale wrote: >> On Wed, Aug 26, 2009 at 12:15 PM, 7stud -- >> wrote: >>> ticket= method returns the string "Ha ha!" �The idea is to keep the >>> semantics consistent. �Under the hood, it's a method call; but it looks >>> like an assignment and behaves like an assignment with respect to its >>> value as an expression. >>> ------ >>> p. 72, The Well Grounded Rubyist >> >> I know what David is getting at here, but that first sentence isn't >> exactly true, although I'll grant a pedagogical license for it. >> >> It's not that the return value isn't what you think, it's that it's >> ignored when the setter method is called from the sugary syntax of an >> assignment. > > It sounds like you are trying to make a distinction between the sugared > syntax and the normal method call syntax, but... > > a1 = A.new > puts a1.x = 10 > > a2 = A.new > puts a2.x=(10) > both versions return the same thing. Because they are both using the assignment sugar. Parenthesizing the 10 doesn't change that. >> Note that he says that ticket.price = 63.00 evaluates to >> 63.00 "even if the ticket= method returns the string "Ha Ha!".  Which >> is different than saying ticket= returns 63.00 instead of "what you >> might think." >> > > So are you faulting his use of the phrase "returns the string "Ha, ha!" > because the method doesn't actually return "Ha, ha!"--it returns 63.00? David already answered this one, he understood. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale