[]

prc[params,...] â obj Instance Public methods Invokes the block, setting the block's parameters to the values in params using something close to method calling semantics. Generates a warning if multiple values are passed to a proc that expects just one (previously this silently converted the parameters to an array). Note that prc.() invokes prc.call() with the parameters given. It's a syntax sugar to hide âcallâ. For procs created using lambda or ->() an error is genera

arity

prc.arity â fixnum Instance Public methods Returns the number of arguments that would not be ignored. If the block is declared to take no arguments, returns 0. If the block is known to take exactly n arguments, returns n. If the block has optional arguments, return -n-1, where n is the number of mandatory arguments. A proc with no argument declarations is the same a block declaring || as its arguments. proc {}.arity #=> 0 proc {||}.arity #=> 0 proc {|a|}.ar

binding

prc.binding â binding Instance Public methods Returns the binding associated with prc. Note that Kernel#eval accepts either a Proc or a Binding object as its second parameter. def fred(param) proc {} end b = fred(99) eval("param", b.binding) #=> 99

call

prc.call(params,...) â obj Instance Public methods Invokes the block, setting the block's parameters to the values in params using something close to method calling semantics. Generates a warning if multiple values are passed to a proc that expects just one (previously this silently converted the parameters to an array). Note that prc.() invokes prc.call() with the parameters given. It's a syntax sugar to hide âcallâ. For procs created using lambda or ->() an error is genera

curry

prc.curry â a_procprc.curry(arity) â a_proc Instance Public methods Returns a curried proc. If the optional arity argument is given, it determines the number of arguments. A curried proc receives some arguments. If a sufficient number of arguments are supplied, it passes the supplied arguments to the original proc and returns the result. Otherwise, returns another curried proc that takes the rest of arguments. b = proc {|x, y, z| (x||0) + (y||0) + (z||0) } p b.curry[1][2]

hash

prc.hash â integer Instance Public methods Returns a hash value corresponding to proc body.

inspect

inspect() Instance Public methods Alias for: to_s

lambda?

prc.lambda? â true or false Instance Public methods Returns true for a Proc object for which argument handling is rigid. Such procs are typically generated by lambda. A Proc object generated by proc ignores extra arguments. proc {|a,b| [a,b] }.call(1,2,3) #=> [1,2] It provides nil for missing arguments. proc {|a,b| [a,b] }.call(1) #=> [1,nil] It expands a single array argument. proc {|a,b| [a,b] }.call([1,2]) #=> [1,2] A Proc object generated by lambda doe

parameters

prc.parameters â array Instance Public methods Returns the parameter information of this proc. prc = lambda{|x, y=42, *other|} prc.parameters #=> [[:req, :x], [:opt, :y], [:rest, :other]]

source_location

prc.source_location â [String, Fixnum] Instance Public methods Returns the Ruby source filename and line number containing this proc or nil if this proc was not defined in Ruby (i.e. native)