Skip to content

Commit 396d503

Browse files
committed
Document Str.Numeric/.Int
1 parent ab0bd7a commit 396d503

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

doc/Type/Str.pod6

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,32 @@ say "foo[bar][baz]bada".match('ba', :x(2)); # OUTPUT: «(「ba」 「ba」
220220
221221
=end code
222222
223+
=head2 method Numeric
224+
225+
Defined as:
226+
227+
method Numeric(Str:D: --> Numeric:D)
228+
229+
Coerces the string to L<Numeric>. L<Fails|/routine/fail> with C<X::Str::Numeric>
230+
if the coersion cannot be done.
231+
232+
Only Unicode characters with property C<Nd>, as well as leading and trailing
233+
whitespace are allowed, with the special case of the empty string being coerced
234+
to C<0>. Synthetic codepoints (e.g. C<"7\x[308]">) are forbidden.
235+
236+
While C<Nl> and C<No> characters can be used as numeric literals
237+
in the language, their conversion via C<Str.Numeric> will fail, by design.
238+
See L«unival|/routine/unival» if you need to coerse such characters to
239+
C<Numeric>.
240+
241+
=head2 method Int
242+
243+
Defined as:
244+
245+
method Int(Str:D: --> Int:D)
246+
247+
Coerces the string to L<Int>, using the same rules as
248+
L«C<Str.Numeric>|/type/Str#method_Numeric>.
223249
224250
=head2 routine parse-base
225251

0 commit comments

Comments
 (0)