Method: Kernel#demand

Defined in:
lib/core/facets/lazy.rb

#demand(promise) ⇒ Object

Forces the result of a promise to be computed (if necessary) and returns the bare result object. Once evaluated, the result of the promise will be cached. Nested promises will be evaluated together, until the first non-promise result.

If called on a value that is not a promise, it will simply return it.



218
219
220
221
222
223
224
# File 'lib/core/facets/lazy.rb', line 218

def demand( promise )
  if promise.respond_to? :__result__
    promise.__result__
  else # not really a promise
    promise
  end
end