Created
August 12, 2010 00:12
-
-
Save HotFusionMan/520063 to your computer and use it in GitHub Desktop.
passing_unknown_number_of_arguments_through_to_another_method.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent | |
def initialize( a, b ) | |
@a = a | |
@b = b | |
end | |
attr_reader :a, :b | |
end | |
class Child < Parent | |
def initialize( *args ) | |
@p = 't' | |
super( *args ) | |
end | |
attr_reader :p | |
end | |
c = Child.new( 1, 2 ) | |
puts 'value below should be "1":' | |
puts c.a | |
puts 'value below should be "2":' | |
puts c.b | |
puts 'value below should be "t":' | |
puts c.p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment