Inverted syntax: Difference between revisions

Added Wren
(Latitude language added)
(Added Wren)
Line 1,274:
; if expr cond
~@if expr cond</lang>
 
=={{header|Wren}}==
Follows the lines of the Go example which is probably the nearest Wren can get to inverted syntax also.
 
Again, simulating inverted syntax with assignment is not possible.
<lang ecmascript>class IBool {
construct new(b) {
if (!(b is Bool)) Fiber.abort("B must be a boolean")
_b = b
}
 
iff(cond) { cond ? _b : !_b }
}
 
var itrue = IBool.new(true)
 
var needUmbrella
var raining = true
 
// normal syntax
if (raining) needUmbrella = true
System.print("Is it raining? %(raining). Do I need an umbrella? %(needUmbrella)")
 
// inverted syntax
raining = false
needUmbrella = itrue.iff(raining)
System.print("Is it raining? %(raining). Do I need an umbrella? %(needUmbrella)")</lang>
 
{{out}}
<pre>
Is it raining? true. Do I need an umbrella? true
Is it raining? false. Do I need an umbrella? false
</pre>
 
=={{header|zkl}}==
9,482

edits