class Creature
def initialize name, hp
@name, @hp = name, hp
end
end
class Hostile < Creature
def initialize name, hp, ap
super name, hp
@ap = ap
end
end
Another way to super
&:
&:
The ampersand-colon combo turns out to be quite useful in saving keystrokes. What I had been doing was creating a new array of numbers. To do so quickly, I needed to use %w, which makes an array of strings.
ary = %w(23 45 68 120 345 760 1220)
The old way I converted to a number was the following:
ary.map! { |x| x.to_i }
(Naturally, I prefer map over collect, which does the same thing, not just because of the keystroke, but because I used Scheme before.) I discovered a shorter way:
ary.map!(&:to_i)
Actually, instead of doing it separately, why not combine the whole thing?
ary = %w(23 45 68 120 345 760 1220).map(&:to_i)
It saves using exclamation point and feels less dangerous.
Ruby’s super
class Person
def initialize(name)
@name = name
end
def name
return @name
end
end
class Doctor < Person
def name
“Dr. “ + super
end
end
That, in short, is how super works. Taken from Beginning Ruby by Peter Cooper.
super
in short calls up the parent class’ instance method.
Obama Turns 50 Despite Republican Opposition | The Onion – Americas Finest News Source
Atlantis
Like most endings, even though I get the sense of historic proportion of not having a shuttle space program, I also recognize that it was a flawed endeavor. It was not reusable in the way that Nixon claimed it was. Once such a program started, everything else ended because we no longer strove to go to the moon again, to Mars or to find other means of transportation, to defy the laws of physics.
Like most endings, I do not feel the tragedy because the shuttle program was born before my time. It felt like a common occurrence to have something flying off into space–perhaps I lost the capacity for awe.
Gauche and sinister
Such is left-handedness. I am not left-handed, but I am sensitive to their plight.
Scenarios For American Collapse
How America will collapse by 2025 – U.S. Economy – Salon.com.
Via Andrew Sullivan. It is very credible.
Comfort
“What the English call ‘comfort’ is something inexhaustible and illimitable. Others can reveal to you that what you take to be comfort at any stage is discomfort, and these discoveries never come to an end. Hence the need for greater comfort does not exactly arise within you directly; it is suggested to you by those who hope to make a profit from its creation.” — Hegel
Bacteria ‘R’ Us
In essence, the argument centers on whether the biosphere should be characterized as a tree of life or an interactive web.
via Bacteria ‘R’ Us