1
0
forked from Mirror/wren

Use "construct" instead of "this" to define constructors.

This commit is contained in:
Bob Nystrom
2015-07-21 07:24:53 -07:00
parent ed8ec262e4
commit 71ab3ca887
31 changed files with 68 additions and 81 deletions

View File

@ -172,18 +172,18 @@ constructor, like so:
:::dart
class Unicorn {
this new(name, color) {
construct new(name, color) {
IO.print("My name is " + name + " and I am " + color + ".")
}
}
The `this` before the method name makes it a constructor. The `new` isn't
The `construct` before the method name makes it a constructor. The `new` isn't
special. Constructors can have any name you like, which lets you clarify how it
creates the instance:
:::dart
class Unicorn {
this brown(name) {
construct brown(name) {
IO.print("My name is " + name + " and I am brown.")
}
}

View File

@ -28,8 +28,8 @@ Some people like to see all of the reserved words in a programming language in
one lump. If you're one of those folks, here you go:
:::dart
break class else false for foreign if import in
is null return static super this true var while
break class construct else false for foreign if import
in is null return static super this true var while
## Identifiers