The ord routine

Combined from primary sources listed below.

In class Str ( Type/Str )§

See primary docmentation in context for routine ord.

routine ord§

multi        ord(Str:D  --> Int:D)
multi method ord(Str:D: --> Int:D)

Returns the codepoint number of the base characters of the first grapheme in the string.

Example:

ord("A"); # 65
"«".ord;  # 171

In class Cool ( Type/Cool )§

See primary docmentation in context for routine ord.

routine ord§

sub ord(Str(Cool))
method ord()

Coerces the invocant (or in sub form, its argument) to Str, and returns the Unicode code point number of the first code point.

say 'a'.ord;            # OUTPUT: «97␤»

The inverse operation is chr.

Mnemonic: returns an ordinal number