forked from AbleScript/ablescript
Improved type coercions
This commit is contained in:
parent
8d24ad5528
commit
f18742a9b3
|
@ -226,16 +226,10 @@ impl Value {
|
||||||
match self {
|
match self {
|
||||||
Value::Nul => Abool::Never,
|
Value::Nul => Abool::Never,
|
||||||
Value::Str(s) => match s.to_lowercase().as_str() {
|
Value::Str(s) => match s.to_lowercase().as_str() {
|
||||||
"never" => Abool::Never,
|
"never" | "no" | "🇳🇴" => Abool::Never,
|
||||||
"sometimes" => Abool::Sometimes,
|
"sometimes" => Abool::Sometimes,
|
||||||
"always" => Abool::Always,
|
"always" | "yes" => Abool::Always,
|
||||||
s => {
|
s => (!s.is_empty()).into(),
|
||||||
if s.is_empty() {
|
|
||||||
Abool::Never
|
|
||||||
} else {
|
|
||||||
Abool::Always
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Value::Int(x) => match x.cmp(&0) {
|
Value::Int(x) => match x.cmp(&0) {
|
||||||
std::cmp::Ordering::Less => Abool::Never,
|
std::cmp::Ordering::Less => Abool::Never,
|
||||||
|
|
Loading…
Reference in a new issue