From f18742a9b3b8d841f39cbb78296cf8542c59d3d2 Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 30 Mar 2022 20:56:59 +0200 Subject: [PATCH] Improved type coercions --- ablescript/src/variables.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index b30601a..2f93eb5 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -226,16 +226,10 @@ impl Value { match self { Value::Nul => Abool::Never, Value::Str(s) => match s.to_lowercase().as_str() { - "never" => Abool::Never, + "never" | "no" | "🇳🇴" => Abool::Never, "sometimes" => Abool::Sometimes, - "always" => Abool::Always, - s => { - if s.is_empty() { - Abool::Never - } else { - Abool::Always - } - } + "always" | "yes" => Abool::Always, + s => (!s.is_empty()).into(), }, Value::Int(x) => match x.cmp(&0) { std::cmp::Ordering::Less => Abool::Never,