Hash :
d41f2661
Author :
Thomas de Grivel
Date :
2025-05-18T20:36:15
fix doc nav and links
Booleans can have only two values : false or true.
They can be casted to integer types, false being 0 and
true being 1.
You can cast any type to a boolean : integers 0 and character NUL
being false and everything else being true. This is useful for
boolean operations : accept any tag as a condition and if it
evaluates to true after a cast then proceed. This is how
if_then_else and while and many KC3 operators are implemented.
ikc3> true && true
true
ikc3> true && false
false
ikc3> if "" do "ok" else "ko" end
"ok"
ikc3> if 1 do "ok" else "ko" end
"ok"
ikc3> if 0 do "ko" else "ok" end
"ok"
ikc3> (Bool) ""
true
ikc3> (Bool) 1
true
ikc3> (Bool) 0
false
ikc3> "ok" == "ok"
true
ikc3> "ok" == "ko"
false
Top : KC3 documentation
Previous : 1.03 Block
Next : 1.05 Callable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
# 1.4 Bool
Booleans can have only two values : `false` or `true`.
They can be casted to integer types, `false` being `0` and
true being `1`.
You can cast any type to a boolean : integers `0` and character NUL
being `false` and everything else being `true`. This is useful for
boolean operations : accept any tag as a condition and if it
evaluates to `true` after a cast then proceed. This is how
`if_then_else` and `while` and many KC3 operators are implemented.
## 1.4.1 Examples
```
ikc3> true && true
true
ikc3> true && false
false
ikc3> if "" do "ok" else "ko" end
"ok"
ikc3> if 1 do "ok" else "ko" end
"ok"
ikc3> if 0 do "ko" else "ok" end
"ok"
ikc3> (Bool) ""
true
ikc3> (Bool) 1
true
ikc3> (Bool) 0
false
ikc3> "ok" == "ok"
true
ikc3> "ok" == "ko"
false
```
---
Top : [KC3 documentation](../)
Previous : [1.03 Block](1.03_Block)
Next : [1.05 Callable](1.05_Callable)