16 lines
653 B
Text
16 lines
653 B
Text
/**
|
|
Logical operations, in Neko
|
|
*/
|
|
|
|
/* For logical operations, values need to be explicitly treated as boolean */
|
|
/* Only null, false and 0 evaluate as false with $istrue() */
|
|
|
|
var logical = 1
|
|
if logical $print("literal 1 tests true\n") else $print("literal 1 tests false\n")
|
|
if $istrue(logical) $print("$istrue(1) tests true\n")
|
|
|
|
/* supports && logical AND, || logical OR, $not(value) the opposite of $istrue() */
|
|
|
|
if $istrue(logical) && logical > 0 $print("true path for logical AND\n")
|
|
if $istrue(logical) || logical > 1 $print("true path for logical OR\n")
|
|
if $not(logical) $print("true path for $not(1)\n") else $print("false path for $not(1)\n")
|