Course of Raku / Advanced / Operators / Types of Raku operators / Exercises / Boolean of a value

Solution: Boolean of a value

Here is a possible solution to the task.

Code

say ?0;
say ?5;

🦋 You can find the source code in the file boolean-of-a-value.raku.

Output

False
True

Comments

  1. ? is a prefix operator: it comes before its operand and returns the operand’s Boolean value.

  2. 0 is false and 5 is true, so the program prints False and True.

Course navigation

Boolean of a value   |   Subscript a hash