Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HotFusionMan/520063 to your computer and use it in GitHub Desktop.
Save HotFusionMan/520063 to your computer and use it in GitHub Desktop.
passing_unknown_number_of_arguments_through_to_another_method.rb
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