class A
def foo
[1, 2, 3]
end
end
class B < A
def foo
super.map{ |n| n * 2 }
end
end
puts A.new.foo.to_s
puts B.new.foo.to_s
Output
[1, 2, 3]
[2, 4, 6]
class A
def foo
[1, 2, 3]
end
end
class B < A
def foo
super.map{ |n| n * 2 }
end
end
puts A.new.foo.to_s
puts B.new.foo.to_s
Output
[1, 2, 3]
[2, 4, 6]
Be First to Comment