Skip to content

Commit ba5a39a

Browse files
authored
Update bools.xw
1 parent d8c47e2 commit ba5a39a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

modules/std/types/bools.xw

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ Alias BoolArray:Bool[] 'Added iDkP 2025-07-09!
2121

2222
'---------------------- Utils: Old Bool type
2323

24+
#rem wonkeydoc Bool to Ternary.
25+
@author iDkP from GaragePixel
26+
@since 2025-07-21
27+
Implicite conversion from bool to int is possible. In this case:
28+
- if v=True return 1
29+
- if v=False return 0
30+
But this function is special:
31+
- if v=True return 1
32+
- if v=False return -1
33+
... as it's intented to be used to cast a binary compare functions, sometimes with a sort.
34+
#end
35+
Function BoolToTernary:Int( v:Bool )
36+
'if v=true return 1
37+
'if v=false return -1
38+
Return v=False ? -1 Else v
39+
End
40+
2441
Function Is:Bool(a:Bool)
2542
'Deprecated int32 boolean version, for the reciprocal
2643
Return a=True

0 commit comments

Comments
 (0)