Course of Raku / Essentials / Strings / String length
Quiz: The length of a phrase
What will the .chars
method return for the following strings?
4 | 'Raku' — (: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :) | |
13 | 'Raku & Rakudo' — (: 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 :) | Spaces are also countable. |
6 | 'Ça va?' — (: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :) | Ç is a single Unicode character. |
0 | '' — (: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :) | An empty string. |
2 | '中国' — (: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :) | More than two bytes in UTF-8, but still only two characters. |
Course navigation
← Strings / Escaping special characters | 💪 Exercises: Strings →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська