Inverted syntax: Difference between revisions

m
(add RPL)
Line 606:
 
@inv println("Wow! Lucky Guess!") if true else println("Not!") end</syntaxhighlight>
 
=={{header|Koka}}==
Using the byref function and infix operators we can get both inverted assignments as well as inverted conditionals in Koka! However, the branch to the conditional is evaluated prior to the condition unless you explicitly delay it or accept a closure.
 
<syntaxhighlight lang="koka">
fun (=:)(c: c, v: local-var<h, c>): <local<h>> ()
v := c
 
fun (?)(c: c, b: bool): e maybe<c>
if b then Just(c) else Nothing
 
fun main()
var x := 4
6 =: std/core/types/byref(x)
x.println
val res = "Yes" ? True
match res
Just(a) -> println(a)
Nothing -> throw("Nothing")
</syntaxhighlight>
 
{{out}}
<pre>
6
Yes
</pre>
 
=={{header|Kotlin}}==
24

edits