Skip to content

Instantly share code, notes, and snippets.

@meaganewaller
Created January 1, 2015 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meaganewaller/e343f72d9197a7dc5ac9 to your computer and use it in GitHub Desktop.
Save meaganewaller/e343f72d9197a7dc5ac9 to your computer and use it in GitHub Desktop.
liskov substitution principle
shapes = [Square.new, Rectangle.new]
def set_rectangle_width(shapes)
shapes.each do |shape|
shape.width = 5
shape.height = 6
end
end
class Rectangle
attr_accessor :width, :height
end
class Square
attr_accessor :side
def height=(height)
@side = height
end
def width=(width)
@side = width
end
def width
@side
end
def height
@side
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment