Method: Proc.new

Defined in:
proc.c

.new {|...| ... } ⇒ Proc

Creates a new Proc object, bound to the current context.

proc = Proc.new { "hello" }
proc.call   #=> "hello"

Raises ArgumentError if called without a block.

Proc.new    #=> ArgumentError

Yields:

  • (...)

Returns:



828
829
830
831
832
833
834
835
# File 'proc.c', line 828

static VALUE
rb_proc_s_new(int argc, VALUE *argv, VALUE klass)
{
    VALUE block = proc_new(klass, FALSE);

    rb_obj_call_init_kw(block, argc, argv, RB_PASS_CALLED_KEYWORDS);
    return block;
}