lib/dry/monads/right_biased.rb
# Calls the passed in Proc object with value stored in self
# and returns the result.
#
# If proc is nil, it expects a block to be given and will yield to it.
#
# @example
#   Dry::Monads.Right(4).bind(&:succ) # => 5
#
# @param [Array<Object>] args arguments that will be passed to a block
#                             if one was given, otherwise the first
#                             value assumed to be a Proc (callable)
#                             object and the rest of args will be passed
#                             to this object along with the internal value
# @return [Object] result of calling proc or block on the internal value
Calls the passed in Proc object with value stored in self
and returns the result.

If proc is nil, it expects a block to be given and will yield to it.
Calls the passed in Proc object with value stored in self and returns the result . If proc is nil it expects a block to be given and will yield to it .
def bind(*args, **kwargs)
          if args.empty? && !kwargs.empty?
            vargs, vkwargs = destructure(@value)
            kw = [kwargs.merge(vkwargs)]
          else
            vargs = [@value]
            kw = kwargs.empty? ? EMPTY_ARRAY : [kwargs]
          end
          if block_given?
            yield(*vargs, *args, *kw)
          else
            obj, *rest = args
            obj.(*vargs, *rest, *kw)
          end
        end
def bind ( * args , ** kwargs ) if args . empty? && ! kwargs . empty? vargs , vkwargs = destructure ( @value ) kw = [ kwargs . merge ( vkwargs ) ] else vargs = [ @value ] kw = kwargs . empty? ? EMPTY_ARRAY : [ kwargs ] end if block_given? yield ( * vargs , * args , * kw ) else obj , * rest = args obj . ( * vargs , * rest , * kw ) end end
Calls the passed in Proc object with value stored in self
and returns the result.
Calls the passed in Proc object with value stored in self and returns the result .
result of calling proc or block on the internal value
result of calling proc or block on the internal value
Object
args
<not_specific>
kwargs
<not_specific>
<not_specific>
args arguments that will be passed to a block if one was given, otherwise the first value assumed to be a Proc (callable) object and the rest of args will be passed to this object along with the internal value
args arguments that will be passed to a block if one was given otherwise the first value assumed to be a Proc ( callable ) object and the rest of args will be passed to this object along with the internal value
example
None