Skip to content

Instantly share code, notes, and snippets.

@markson
Created May 29, 2013 03:00
Show Gist options
  • Save markson/5667686 to your computer and use it in GitHub Desktop.
Save markson/5667686 to your computer and use it in GitHub Desktop.
class Rectangle
attr_accessor :width, :height
def initialize(width, height)
@width = width
@height = height
end
end
class Square < Rectangle
def initialize(length)
super(length, length)
end
def width=(number)
super(number)
@height = number
end
def height=(number)
super(number)
@width = number
end
end
s = Square.new(100)
s.width = 50
puts s.height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment