We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Rectangle { _(height = 1, width = 1) area() -> this.height * this.width } class Square : Rectangle { _(a = 1) { super(a, a) } toRect(mul = 1) -> new Rectangle(this.height, this.width * mul) } let rect = new Rectangle(2, 5) log(rect) // Rectangle { height: 2, width: 5 } log(rect.area()) // 10 // this will throw an error // log(rect.toRect(2)) // unknown method let square = new Square(4) log(square) // Square { height: 4, width: 4 } log(square.area()) // 16 log(square.toRect(2)) // Rectangle { height: 4, width: 8 } Rectangle.prototype.toSquare = (fromHeight = true) -> { if (fromHeight) { return new Square(this.height) } return new Square(this.width) } log(rect.toSquare()) // Square { height: 2, width: 2 }
The text was updated successfully, but these errors were encountered:
closed. see #10
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: