Ruby/Reflection/object id
Материал из Wiki.crossplatform.ru
Содержание |
Check the object_id before and after replace
call = "All hands on deck!" # => "All hands on deck!" call.object_id # => 1624370 call.replace "All feet on deck!" # => "All feet on deck!" call.object_id # => 1624370
Check the object_id before and after the assignment
call = "All hands on deck!" # => "All hands on deck!" call.object_id # => 1600420 call = "All feet on deck!" # => "All feet on deck!" call.object_id # => 1009410
Each object has its own numeric object ID.
# You can find out what this ID is with the object_id method from Object. myString = "asdf" whitman = myString # copy one string object to another whitman == myString # => true myString.object_id # => 968680 whitman.object_id # => 968680
object_id is not changing
10.times { puts "test".object_id }