Course of Raku / Essentials / Boolean type / Boolean operations with other types

Quiz: Boolean operations with non-Boolean data

What is the result of each line of code in the below examples?

1

True True && True is (: True, False :)  
string 'True' 'True' && 'True' is a (: Boolean True, Boolean False, string 'True', string 'False' :) These are strings, which in Boolean context are True values.
string 'Beta' 'Alpha' && 'Beta' is a (: Boolean True, Boolean False, string 'Alpha', string 'Beta' :) The result is the second string.

2

True True || True is (: True, False :)  
string 'True' 'True' || 'True' is a (: Boolean True, Boolean False, string 'True', string 'False' :)  
string 'Alpha' 'Alpha' || 'Beta' is a (: Boolean True, Boolean False, string 'Alpha', string 'Beta' :) The result is the first string.

3

200 100 && 200 is (: 100, 200, True, False, Nil :)  
100 100 || 200 is (: 100, 200, True, False, Nil :)  
Nil 100 ^^ 200 is (: 100, 200, True, False, Nil :) Nil is the value to represent the absense of value.

Course navigation

Boolean type / Boolean operations   |   💪 Exercises: Boolean type