July 2011
Intermediate to advanced
400 pages
8h 46m
English
Parentheses matter when calling the superclass! If the argument list is empty and no parentheses are used, all arguments are passed to the superclass. But if the argument list is empty and parentheses are used, no arguments are passed to the superclass:
super_args.rb
# This passes a, b, c to the superclass def initialize( a, b, c, d, e, f ) super( a, b, c ) end # This passes a, b, c to the superclass def initialize( a, b, c ) super end # This passes no arguments to the superclass def initialize( a, b, c) super() end
To gain a better understanding of the use of super, see Digging Deeper in Digging Deeper.
Read now
Unlock full access