Ruby 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
They can also have class methods:
class Hello
def self.say_hi
puts "HI"
end
end
Hello.say_hi # "HI