In Str§

See primary documentation in context for routine val

multi val(*@maybevals)
multi val(Slip:D \maybevals)
multi val(List:D \maybevals)
multi val(Pair:D \ww-thing)
multi val(\one-thing)
multi val(Str:D $MAYBEVAL:$val-or-fail)

Given a Str that may be parsable as a numeric value, it will attempt to construct the appropriate allomorph, returning one of IntStr, NumStr, RatStr or ComplexStr or a plain Str if a numeric value cannot be parsed.

say val("42").^name;    # OUTPUT: «IntStr␤» 
say val("42e0").^name;  # OUTPUT: «NumStr␤» 
say val("42.0").^name;  # OUTPUT: «RatStr␤» 
say val("42+0i").^name# OUTPUT: «ComplexStr␤»

You can use the plus and minus sign, as well as the Unicode "Minus Sign" as part of the String

say val("−42");         # OUTPUT: «−42␤»

While characters belonging to the Unicode categories Nl (number letters) and No (other numbers) can be used as numeric literals in the language, they will not be converted to a number by val, by design, and using val on them will produce a failure. The same will happen with synthetic numerics (such as 7̈ ). See unival if you need to convert such characters to Numeric.