From: Frantisek Psotka Date: 2008-03-10T23:11:54+09:00 Subject: Re: newbie question yes, i can write a = b || a but isn't it more complex. imagine that b is nil. then a = a will be evaluated? maybe time for feature request? new operator a =|| (a = b if b) (variable = params[:nice_symbol] if params[:nice_symbol] doesnt look very nice) Lars wrote: > On Mar 10, 11:50 am, Farrel Lifson wrote: >> On 10/03/2008, Frantisek Psotka wrote: >> >> > is in ruby operator for: >> >> > a = b if b >> >> > a (operator) b >> >> a ||= b > > "a ||= b" means "a = b unless a". > > I don't think there is an operator for "a = b if b". > > Luckily, "a = b if b" is valid ruby code. "a = b || a" or "a = (b or > a)" would also work. -- Posted via http://www.ruby-forum.com/.