RosettaCodeData/Task/Logical-operations/Neko/logical-operations.neko
2019-09-12 10:33:56 -07:00

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")