forked from Mirror/wren
Use "construct" instead of "this" to define constructors.
This commit is contained in:
@ -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.")
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user