Feature #6373 » itself.diff
include/ruby/intern.h | ||
---|---|---|
VALUE rb_obj_alloc(VALUE);
|
||
VALUE rb_obj_clone(VALUE);
|
||
VALUE rb_obj_dup(VALUE);
|
||
VALUE rb_obj_itself(VALUE);
|
||
VALUE rb_obj_init_copy(VALUE,VALUE);
|
||
VALUE rb_obj_taint(VALUE);
|
||
VALUE rb_obj_tainted(VALUE);
|
object.c | ||
---|---|---|
return dup;
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* obj.itself -> an_object
|
||
*
|
||
* Returns <i>obj</i>.
|
||
*
|
||
* string = 'my string' #=> "my string"
|
||
* string.itself.object_id == string.object_id #=> true
|
||
*
|
||
*/
|
||
VALUE
|
||
rb_obj_itself(VALUE obj)
|
||
{
|
||
return obj;
|
||
}
|
||
/* :nodoc: */
|
||
VALUE
|
||
rb_obj_init_copy(VALUE obj, VALUE orig)
|
||
... | ... | |
rb_define_method(rb_mKernel, "singleton_class", rb_obj_singleton_class, 0);
|
||
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);
|
||
rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0);
|
||
rb_define_method(rb_mKernel, "itself", rb_obj_itself, 0);
|
||
rb_define_method(rb_mKernel, "initialize_copy", rb_obj_init_copy, 1);
|
||
rb_define_method(rb_mKernel, "initialize_dup", rb_obj_init_dup_clone, 1);
|
||
rb_define_method(rb_mKernel, "initialize_clone", rb_obj_init_dup_clone, 1);
|
test/ruby/test_object.rb | ||
---|---|---|
$VERBOSE = @verbose
|
||
end
|
||
def test_itself
|
||
object = Object.new
|
||
assert_equal object, object.itself
|
||
assert_equal object.object_id, object.itself.object_id
|
||
end
|
||
def test_dup
|
||
assert_raise(TypeError) { 1.dup }
|
||
assert_raise(TypeError) { true.dup }
|
- « Previous
- 1
- 2
- Next »