Permalink
Browse files

Update to latest candor

  • Loading branch information...
creationix committed Mar 27, 2012
1 parent b34ee3a commit 437449303f5466b1e9c93e584211690f9a582126
Showing with 9 additions and 11 deletions.
  1. +1 −1 deps/candor
  2. +8 −10 test-objects.can
View
@@ -1,15 +1,13 @@
print = global.print
p = global.prettyPrint
-Object = {
- new: (self, args...) {
- obj = new self
- obj:initialize(args...)
- return obj
- }
+new = (prototype, args...) {
+ obj = clone prototype
+ obj:initialize(args...)
+ return obj
}
-Rectangle = new Object
+Rectangle = {}
Rectangle.getArea = (self) {
return self.w * self.h
}
@@ -19,17 +17,17 @@ Rectangle.initialize = (self, w, h) {
}
p("Rectangle", Rectangle)
-Square = new Rectangle
+Square = clone Rectangle
Square.initialize = (self, s) {
self.w = s
self.h = s
}
p("Square", Square)
-rect = Rectangle:new(3, 5)
+rect = new(Rectangle, 3, 5)
p("rect", rect)
print("Rectangle 3x5 = " + rect:getArea())
-square = Square:new(4)
+square = new(Square, 4)
p("square", square)
print("Square 4x4 = " + square:getArea())

0 comments on commit 4374493

Please sign in to comment.