APIdock / Ruby
/
method

singleton_method_added

ruby latest stable - Class: Numeric
singleton_method_added(p1)
public

Trap attempts to add methods to Numeric objects. Always raises a TypeError.

Numerics should be values; singleton_methods should not be added to them.

static VALUE
num_sadded(VALUE x, VALUE name)
{
 ID mid = rb_to_id(name);
 /* ruby_frame = ruby_frame->prev; */ /* pop frame for "singleton_method_added" */
 rb_remove_method_id(rb_singleton_class(x), mid);
 rb_raise(rb_eTypeError,
 "can't define singleton method \"%"PRIsVALUE"\" for %"PRIsVALUE,
 rb_id2str(mid),
 rb_obj_class(x));
 UNREACHABLE;
}

AltStyle によって変換されたページ (->オリジナル) /