[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

context of self

Sijo Kg

1/2/2009 10:15:00 AM

Hi
I tried like

class First
def initialize
puts 'in First class'+self.inspect
end
end
class Second < First
def initialize
super
puts 'in second class'+self.inspect
end
end

Second.new
I got result as
in First class#<Second:0xb7f61820>
in second class#<Second:0xb7f61820>

So is #<Second:0xb7f61820> always means from where I call the
def? I did not understand it

Thanks in advance
Sijo
--
Posted via http://www.ruby-....

3 Answers

Sebastian Hungerecker

1/2/2009 10:50:00 AM

0

Sijo Kg wrote:
> Second.new
> =C2=A0 =C2=A0 =C2=A0 =C2=A0I got result as
> in First class#<Second:0xb7f61820>
> in second class#<Second:0xb7f61820>
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0So is #<Second:0xb7f61820> always means=
from where I call the
> def? I did not understand it

self is the current object (in this case the object just constructed by new=
).=20
The output of inspect does not change depending on where inspect is called=
=20
from, nor does the value of self change when you call super.
In other words: if you call self.inspect and self is an object of class=20
Second, you'll call Second#inspect which, unless overridden, will return
"#<Second:bla>", and if you call Second.new, self will indeed be an object
of class Second.

HTH,
Sebastian
=2D-=20
Jabber: sepp2k@jabber.org
ICQ: 205544826

photoarts1

1/23/2011 4:08:00 AM

0

On Jan 22, 8:49 pm, faz <pinball_...@live.com> wrote:
> If it just broke off, try soldering it back on and testing.
>
> It sounds like you already have the board in hand.
> Solder the part on and just plug into the connector.
> Turn the machine on and view the optos through a digital camera, the
> opto transmitter will light up in the LCD display of the camera
>
> What have you got to loose?
>
> If not, buy a replacement from Ed at GPE  http://www.greatplainselectronics.com/products.a...
>
> You can buy replacement board sets, but for a few bucks, try it
> yourself.
>
> Best of luck,
> faz

faz

There is not enough leads on the broken part to solder back. Item was
broken off level with base of LED.
Do you happen to know if Ed's LEDs are the correct size for that
particular board?
Just need to know which one I should order.

thanks for your help
p

bigehrl

1/23/2011 6:22:00 PM

0

one of the sets of optos is shorter than the ones you will find on the
parts sites.. i cant recall if it was the transmitter, or the
receiver, but i believe it was the black ones..

if you use the optos you buy individually, they will be too long, and
will interfere with the motion of the 'mushroom' target. i wound up
just buying a new board, and solved the problem..

-jon