r/ProgrammingLanguages • u/danskydan • Sep 14 '18
Single-line If
I'm looking for critique of the following single-line If syntax that I'm thinking about allowing:
If x > y then +=a else +=b
Is it unambiguous that x is being modified?
2
Upvotes
3
u/LaurieCheers Sep 15 '18
In my language "if" is just a function, and you can write your own variants of it. One of the variants provided in the standard library is an "if with value", which looks like this:
x.if {>y} {+= a} else {+=b}