-
-
Save anonymous/8a57e90a0499511f1ea8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/doc/Language/objects.pod b/doc/Language/objects.pod | |
index 1e94d52..6e82e2a 100644 | |
--- a/doc/Language/objects.pod | |
+++ b/doc/Language/objects.pod | |
@@ -462,6 +462,18 @@ positional arguments, you must write your own C<new> method: | |
However this is considered poor practice, because it makes correct | |
initialization of objects from subclasses harder. | |
+In contrast, providing a C<new> candidate with positional parameters that | |
+invokes the C<new> candidate from L<Any> isn't considered poor practice: | |
+ | |
+ =for code :allow<B L> | |
+ class Point { | |
+ has $.x; | |
+ has $.y; | |
+ multi method new($x, $y) { | |
+ self.new(:$x, :$y) | |
+ } | |
+ } | |
+ | |
Another thing to note is that the name C<new> is not special in Perl 6. It | |
is merely a common convention. You can call C<bless> from any method at all, | |
or use C<CREATE> to fiddle around with low-level workings. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment