mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Changed truthiness
This commit is contained in:
@@ -323,6 +323,7 @@ void freeLiteral(Literal literal) {
|
||||
|
||||
bool _isTruthy(Literal x) {
|
||||
if (IS_NULL(x)) {
|
||||
fprintf(stderr, "Null is neither true nor false");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -330,16 +331,6 @@ bool _isTruthy(Literal x) {
|
||||
return AS_BOOLEAN(x);
|
||||
}
|
||||
|
||||
if (IS_INTEGER(x)) {
|
||||
return AS_INTEGER(x) != 0;
|
||||
}
|
||||
|
||||
if (IS_FLOAT(x)) {
|
||||
return AS_FLOAT(x) != 0;
|
||||
}
|
||||
|
||||
//TODO: empty string as falsy?
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user