NYI: Idiom # 340 Last character of string
See programming-idioms.org:
Code
This idiom demonstrates how to retrieve the last character of a string using Fuzion's .codepoint
string functions. The variable 's' is a string and
'c' will be set depending on whether the string is empty or not.
If 's' is empty, 'c' is set to "Empty string". Otherwise, the code uses s.substring_codepoint
along with s.codepoint_length - 1
to extract
the last character of the string.
This code example does not correctly handle characters that consist of multiple Unicode codepoints, such as some emojis or accented characters.
These may be rendered incorrectly, possibly as question marks.
Runnable Example
Runnable Example 2
Example what happens with multiple Unicode codepoints.
last changed: 2025-05-13