Saturday, October 31, 2009

Ruby initialize puzzle (answer part)

(continued from phosphorescence: Ruby initialize puzzle (question part))

The answer is:
qux World
=> #<Sample:0x246f508>

The Ruby method super doesn't mean calling same method of super class, it means calling same method defined in last class.

For example, if same method is defined in super class only, it behaves to rewrite super class's one. But if same method is defined in included module like as this question, it behaves to rewrite included module's one because it's last defined method.

No comments:

Post a Comment