Add new Luau ternary operator (#21)

This commit is contained in:
angifalangi 2022-08-25 20:45:03 -04:00 committed by GitHub
parent b29e25eb86
commit 8ccbba9571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,11 +28,11 @@ macro_rules! impl_write_number {
impl DriverNoContext for Select { impl DriverNoContext for Select {
fn write(&self, w: &mut dyn Write) -> Result<()> { fn write(&self, w: &mut dyn Write) -> Result<()> {
write!(w, "(")?; write!(w, "(if ")?;
Condition(self.condition()).write(w)?; Condition(self.condition()).write(w)?;
write!(w, " and ")?; write!(w, " then ")?;
self.on_true().write(w)?; self.on_true().write(w)?;
write!(w, " or ")?; write!(w, " else ")?;
self.on_false().write(w)?; self.on_false().write(w)?;
write!(w, ")") write!(w, ")")
} }
@ -163,9 +163,9 @@ impl DriverNoContext for CmpOpBoolean<'_> {
impl DriverNoContext for CmpOp { impl DriverNoContext for CmpOp {
fn write(&self, w: &mut dyn Write) -> Result<()> { fn write(&self, w: &mut dyn Write) -> Result<()> {
write!(w, "(")?; write!(w, "(if ")?;
CmpOpBoolean(self).write(w)?; CmpOpBoolean(self).write(w)?;
write!(w, " and 1 or 0)") write!(w, " then 1 else 0)")
} }
} }