diff options
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/value.rs')
-rw-r--r-- | users/tazjin/rlox/src/bytecode/value.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/bytecode/value.rs b/users/tazjin/rlox/src/bytecode/value.rs index 88ff8a695138..dcd238a7cd39 100644 --- a/users/tazjin/rlox/src/bytecode/value.rs +++ b/users/tazjin/rlox/src/bytecode/value.rs @@ -4,3 +4,13 @@ pub enum Value { Bool(bool), Number(f64), } + +impl Value { + pub fn is_falsey(&self) -> bool { + match self { + Value::Nil => true, + Value::Bool(false) => true, + _ => false, + } + } +} |