I am quite new into ruby and stumbled over some strange (at least to me)
Have a look and guess what the output of this code might be:
@@temperature = 0
puts “My body temperature is “[email protected]@temperature.to_s+” degree”
class Spider < Animal
@@temperature = 20
class Horse < Animal
@@temperature = 38
batty = Spider.new
fury = Horse.new
Well, for myself, I’d expected that the result were “My body temperature
is 20 degree” and “My body temperature is 38 degree”.
But surprise, surprise, both animals tell me that they have 38 degree!
The next strange thing is that this effect seems to depend on the order
of the class-definition.
How does this happen? And Why