Course of Raku / Essentials / More about types / Data type conversion / Exercises / True and False strings
Solution: True and False strings
This exercise is similar to the
previous one, but this time, the task is a bit trickier. There are
more ’suspect’ strings that can be treated as False. Let us
explore them.
say ?'';
say ?' ';
say ?' ';
say ?"\n";
say ?'0';
say ?'0.0';From all of these, only the empty string is cast as
False. All other strings, even those that contain only
spaces or an explicit character 0, become
True.
🦋 You can find the full program with the above example in the file true-false-strings.raku.
Course navigation
← True and False strings | Fractional part →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська