Robert Dober wrote:
> You sure could
> def && a, &blk
>   return blk.call if a
>   a
> end
> 
> and
> a && b
> is syntactic sugar for
> &&(a){b}
mmh...the problem is, if you assign to a new local variable inside the
block, like foo && (bar = 42), it matter whether the second operand has
its own scope. but your idea certainly helps when somebody wants to
immitate short-circuit evaluation. like:

class Boolean < Struct.new :value
  def & arg = nil
    value && (arg || yield)
  end
end

False = Boolean.new(false)
True = Boolean.new(true)

i = 0
False & i += 1  # => false
True & i += 1   # => 2

i = 0
False.& { i += 1 }  # => false
True.& { i += 1 }   # => 1

[murphy]