#!/usr/bin/ruby
class ParentClass
def initialize(name)
@name = name
end
end
class ChildClass < ParentClass
def initialize(name, age)
super(name)
@age = age
end
def show
puts "#{@name} = #{@age}"
end
end
x = ChildClass.new "Ivan", "20"
x.show
Ruby Справочник v0.05 © 2007-2024 Igor Salnikov aka SunDoctor