Robert Klemme <bob.news / gmx.net> wrote:
> "Martin DeMello" <martindemello / yahoo.com> schrieb im Newsbeitrag
> >
> > It'd be nice to have an operator like || that only failed for nil - that
> > way 'false' valued variables wouldn't be splatted by the a ||= b idiom.
> 
> Isn't #nil? sufficient?
> 
> foo = nil
> 
> 5.times do
>   foo.nil? and begin
>     foo = false
>     puts "changed"
>   end
> end

That's a lot more verbose, though. And personally, I've only ever used
||= for setting uninitialized values, so it'd definitely have been more
useful to have it distinguish between nil and everythingelse. I suppose
this would work:

	class Object
	  def splat(other)
	    self.nil? ? other : self
	  end
	end

	foo = foo.splat 5

but I still like the <operator>= form.

martin