File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,21 @@ statements in other languages like C<return>, C<last> and many others.
334
334
}
335
335
say f; # OUTPUT « True »
336
336
337
+ = head2 Exponentiation Operator and Prefix Minus
338
+
339
+ say -1²; # -1
340
+ say -1**2; # -1
341
+
342
+ When performing a
343
+ L < regular mathematical calculation|http://www.wolframalpha.com/input/?i=-1%C2%B2 > ,
344
+ the power takes precedence over the minus; so C < -1² > can be written as C < -(1²) > .
345
+ Perl 6 matches these rules of mathematics and the precedence of C < ** > operator is
346
+ tighter than that of the prefix C < - > . If you wish to raise a negative number
347
+ to a power, use parentheses:
348
+
349
+ say (-1)²; # -1
350
+ say (-1)**2; # -1
351
+
337
352
= head1 Subroutine and method calls
338
353
339
354
Subroutine and method calls can be made using one of two forms:
You can’t perform that action at this time.
0 commit comments