> I've just proposed this idea to Groovy and I thought the same semantics would be interesting to have in Ruby too:
>
> http://jira.codehaus.org/browse/GROOVY-5306
>
> This is a minor, but important, difference to the "a ||= 2" syntax.
>
> This would be a caching/memoization operator, and it would allow code like this:
>
> a = nil
> a ?= false # a is false now
> a ?= true # a is still false
>
> This contrasts with
>
> a = nil
> a ||= false # a is false now
> a ||= true # a is true now

If we want something like this, we should provide a non-assignment
version too. Perl uses // for the same purpose:

  sub foo {
    my ($foo, %options) = @_;
    $foo //= 1;
    my $bar = $options{bar} // 2;
    return ($foo, $bar)
  }

  foo(undef, bar => undef)   # => (1, 2)
  foo(0, bar => 0)  # => (0, 0)   (0 is false in Perl)

Although I suspect we rather want to use // for float/exact-division
in the future.