Module: Corefines::Object::Else

Defined in:
lib/corefines/object.rb

Instance Method Summary collapse

Instance Method Details

#else {|self| ... } ⇒ Object

Returns self if self evaluates to true, otherwise returns the evaluation of the block.

Yields:

  • (self)

    gives self to the block.

Returns:

  • (Object)

    self if self evaluates to true, otherwise returns the evaluation of the block.


141
142
143
144
145
146
147
# File 'lib/corefines/object.rb', line 141

module Else
  refine ::Object do
    def else
      self ? self : yield(self)
    end
  end
end