method
object_id
v1_9_3_125 -
Show latest stable
- Class:
Object
object_id()public
Returns an integer identifier for obj. The same number will be returned on all calls to id for a given object, and no two active objects will share an id. Object#object_id is a different concept from the :name notation, which returns the symbol id of name. Replaces the deprecated Object#id.
VALUE
rb_obj_id(VALUE obj)
{
/*
* 32-bit VALUE space
* MSB ------------------------ LSB
* false 00000000000000000000000000000000
* true 00000000000000000000000000000010
* nil 00000000000000000000000000000100
* undef 00000000000000000000000000000110
* symbol ssssssssssssssssssssssss00001110
* object oooooooooooooooooooooooooooooo00 = 0 (mod sizeof(RVALUE))
* fixnum fffffffffffffffffffffffffffffff1
*
* object_id space
* LSB
* false 00000000000000000000000000000000
* true 00000000000000000000000000000010
* nil 00000000000000000000000000000100
* undef 00000000000000000000000000000110
* symbol 000SSSSSSSSSSSSSSSSSSSSSSSSSSS0 S...S % A = 4 (S...S = s...s * A + 4)
* object oooooooooooooooooooooooooooooo0 o...o % A = 0
* fixnum fffffffffffffffffffffffffffffff1 bignum if required
*
* where A = sizeof(RVALUE)/4
*
* sizeof(RVALUE) is
* 20 if 32-bit, double is 4-byte aligned
* 24 if 32-bit, double is 8-byte aligned
* 40 if 64-bit
*/
if (SYMBOL_P(obj)) {
return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
}
if (SPECIAL_CONST_P(obj)) {
return LONG2NUM((SIGNED_VALUE)obj);
}
return (VALUE)((SIGNED_VALUE)obj|FIXNUM_FLAG);
} Related methods
- Instance methods
- !~
- <=>
- ===
- =~
- CSV
- DelegateClass
- Digest
- __getobj__
- __setobj__
- check_signedness
- check_sizeof
- chmod
- class
- clone
- convertible_int
- cp
- create_header
- create_makefile
- dclone
- default_src_encoding
- define_singleton_method
- depend_rules
- dir_config
- display
- dummy_makefile
- dup
- enable_config
- enum_for
- eql?
- extend
- find_executable
- find_header
- find_library
- find_type
- freeze
- frozen?
- hash
- have_const
- have_framework
- have_func
- have_header
- have_library
- have_macro
- have_struct_member
- have_type
- have_var
- help
- httpd
- initialize_clone
- initialize_copy
- initialize_dup
- inspect
- install
- instance_of?
- instance_variable_defined?
- instance_variable_get
- instance_variable_set
- instance_variables
- is_a?
- kind_of?
- ln
- method
- mkdir
- mkmf
- mv
- nil?
- object_id
- pretty_print
- pretty_print_cycle
- psych_to_yaml
- public_method
- public_send
- respond_to?
- respond_to_missing?
- rm
- rmdir
- send
- setup
- singleton_class
- singleton_methods
- sysread
- taint
- tainted?
- tap
- timeout
- to_enum
- to_s
- to_yaml
- to_yaml_properties
- touch
- trust
- try_const
- try_type
- untaint
- untrust
- untrusted?
- wait_writable
- with_config
- xmp
- Class methods
- yaml_tag
- Private methods
-
remove_instance_variable