From: Joshua Ballanco Date: 2009-12-23T14:36:17+09:00 Subject: Re: newbie: if is not null else... On Dec 22, 2009, at 5:53 AM, Stefano Crocco wrote: > On Tuesday 22 December 2009, Alfonso Caponi wrote: >> |Hi forum, >> | >> |how can I replace this PHP syntax with Ruby? >> | >> |$x = (isset($x) and !empty($x)) ? $x : '-'; >> | >> |I would like assign a default value if $x is Null. >> | >> |Thank you very much, >> |Al > > I don't know PHP, so I'm not sure whether this does exactly what you want: > > $x ||= '-' > > This is a short form for > > $x = $x || '-' Correction, it is short form for: $x || $x = '-' ...trust me, we've been over this at least 3 times, at great length, on the mailing list. ;-) Cheers, Josh