Class
A simple Ruby class
class Rectangle
def initialize(length, width)
@length = length
@width = width
end
def area
@length * @width
end
end
rect = Rectangle.new(4,5)
rect.area # => 20
A simple Ruby class
class Rectangle
def initialize(length, width)
@length = length
@width = width
end
def area
@length * @width
end
end
rect = Rectangle.new(4,5)
rect.area # => 20