Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (28 sloc) 0.584 kB
print = global.print
p = global.prettyPrint
new = (prototype, args...) {
obj = clone prototype
obj:initialize(args...)
return obj
}
Rectangle = {}
Rectangle.getArea = (self) {
return self.w * self.h
}
Rectangle.initialize = (self, w, h) {
self.w = w
self.h = h
}
p("Rectangle", Rectangle)
Square = clone Rectangle
Square.initialize = (self, s) {
self.w = s
self.h = s
}
p("Square", Square)
rect = new(Rectangle, 3, 5)
p("rect", rect)
print("Rectangle 3x5 = " + rect:getArea())
square = new(Square, 4)
p("square", square)
print("Square 4x4 = " + square:getArea())
Jump to Line
Something went wrong with that request. Please try again.