call(...)
public
Invokes the meth with the specified arguments, returning the
method’s return value.
m = 12.method("+")
m.call(3)
m.call(20)
Show source
/*
* call-seq:
* meth.call(args, ...) => obj
* meth[args, ...] => obj
*
* Invokes the <i>meth</i> with the specified arguments, returning the
* method's return value.
*
* m = 12.method("+")
* m.call(3) #=> 15
* m.call(20) #=> 32
*/
static VALUE
method_call(argc, argv, method)
int argc;
VALUE *argv;
VALUE method;
{
VALUE result = Qnil; /* OK */
struct METHOD *data;
int safe;
Data_Get_Struct(method, struct METHOD, data);
if (data->recv == Qundef) {
rb_raise(rb_eTypeError, "can't call unbound method; bind first");
}
if (OBJ_TAINTED(method)) {
safe = NOEX_WITH(data->safe_level, 4)|NOEX_TAINTED;
}
else {
safe = data->safe_level;
}
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
result = rb_call0(data->klass,data->recv,data->id,data->oid,argc,argv,data->body,safe);
POP_ITER();
return result;
}