As far as i know, ruby use memory location to generate object's id, normally any dynamic objects(runtime generate objects) will have different object_id, for example "foo".object_id not equal with "foo".object_id. But, any object like number, true, false ,nil and symbol all have fixed object_id

--
rubyonrailsx
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Wednesday, September 19, 2012 at 1:23 AM, roelof wrote:

Hello,

Im trying to learn ruby by using koans.

Now I have to fill in this part.

def test_some_system_objects_always_have_the_same_id
assert_equal --, false.object_id
assert_equal --, true.object_id
assert_equal --, nil.object_id
end

According to the answers I have to fill in like this :

def test_some_system_objects_always_have_the_same_id
assert_equal 0, false.object_id
assert_equal 2, true.object_id
assert_equal 4, nil.object_id
end

But how can I normally know the id of a object ?

Roelof

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com (mailto:rubyonrails-talk@googlegroups.com).
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com (mailto:rubyonrails-talk+unsubscribe@googlegroups.com).
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ym3Iw2DuGgcJ.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 6 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 18, '12 at 5:23p
activeSep 19, '12 at 7:33a
posts6
users5
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase