diff --git a/classes.html b/classes.html index ce6d3ff9..2ffd2649 100644 --- a/classes.html +++ b/classes.html @@ -400,6 +400,19 @@ and won’t have a constructor.
overloaded by arity. A constructor must be a named method with a (possibly empty) argument list. Operators, getters, and setters cannot be constructors. +A constructor returns the instance of the class being created, even if you
+don’t explicitly use return. It is valid to use return inside of a
+constructor, but it is an error to have an expression after the return.
+That rule applies to return this as well, return handles that implicitly inside
+a constructor, so just return is enough.
+return //> valid, returns 'this' + +return variable //> invalid +return null //> invalid +return this //> also invalid ++
A constructor is actually a pair of methods. You get a method on the class:
Unicorn.brown("Dave")