You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/Language/contexts.pod6
+23-17Lines changed: 23 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,13 @@ foo
44
44
45
45
=head1Number X<|number context>
46
46
47
-
This context, and probably all of them except sink above, are I<conversion> or I<interpretation> contexts in the sense that they take an untyped or typed variable and duck-type it to whatever is needed to perform the operation. In some cases that will imply a conversion (from L<Str|/type/Str> to L<Numeric|/type/Numeric>, for instance); in other cases simply an interpretation (L<IntStr|/type/IntStr> will be interpreted as L<Int|/type/Int> or as L<Str|/type/Str>).
47
+
This context, and probably all of them except sink above, are I<conversion> or
48
+
I<interpretation> contexts in the sense that they take an untyped or typed
49
+
variable and duck-type it to whatever is needed to perform the operation. In
50
+
some cases that will imply a conversion (from L<Str|/type/Str> to
51
+
L<Numeric|/type/Numeric>, for instance); in other cases simply an interpretation
52
+
(L<IntStr|/type/IntStr> will be interpreted as L<Int|/type/Int> or as
53
+
L<Str|/type/Str>).
48
54
49
55
I<Number context> is called whenever we need to apply a numerical operation on a
50
56
variable.
@@ -56,7 +62,7 @@ say $not-a-string+$neither-a-string; # OUTPUT: «4»
56
62
=endcode
57
63
58
64
In the code above, strings will be interpreted in numeric context as long as
59
-
there is only some numbers and no other characters. It can have any number of
65
+
there are only a few digits and no other characters. It can have any number of
60
66
leading or trailing whitespace, however.
61
67
62
68
Numeric context can be forced by using arithmetic operators such as C<+> or
@@ -84,16 +90,16 @@ used, for instance, for coercing non-string values so that they can be printed
0 commit comments