Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #6762

Re: what's object_id in irb?

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.ruby
Subject Re: what's object_id in irb?
Date 2013-03-05 22:35 +0100
Message-ID <apn6ogFu075U1@mid.individual.net> (permalink)
References <2c64d5aa-e5a3-4db4-b442-daeace8cb263@googlegroups.com>

Show all headers | View raw


On 05.03.2013 17:30, Massimo Donati wrote:
> Hi everyone i'm running this lines of code:
>
> [home/] irb
> 2.0.0p0 :001 > object_id
>   => 70156571578960
>
>
> I can't really understand what is this object_id referred to since is not called from any object?

It is:

irb(main):001:0> object_id
=> -1073529238
irb(main):002:0> self
=> main
irb(main):003:0> self.object_id
=> -1073529238

Note: self - as any variable - _always_ (no exception!) references an 
instance.

Cheers

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar


Thread

what's object_id in irb? Massimo Donati <mass.donati@gmail.com> - 2013-03-05 08:30 -0800
  Re: what's object_id in irb? Robert Klemme <shortcutter@googlemail.com> - 2013-03-05 22:35 +0100

csiph-web