Hullaballoonatic
07/12/2019, 8:21 PMfoo if (condition)
syntax, like exists in Ruby and other languages. It is superior to if (condition) foo
in that it doesn't allow for multiline, and avoids the problem of:
if (foo)
bar
baz // not in scope
Also maybe drop the condition's enclosing ()
Luke
07/12/2019, 8:27 PMfoo.takeIf { condition }
? 🤔Hullaballoonatic
07/12/2019, 8:27 PMjosephivie
07/12/2019, 8:46 PMif
syntax and is ordered logically. If you're using an auto formatter (which you always should) you'll never run into the grouping issue. If that's the problem we want to solve, I'd be for getting rid of implied curly braces on such statements.
- The proposed syntax gives double meaning to if (condition)
which would make code harder to read.
- Dropping the parens introduces vagueness to the following statement:
fun someName(action:()->Unit):Boolean{}
val someName = true
if someName {}
Hullaballoonatic
07/12/2019, 8:47 PMRuckus
07/12/2019, 8:51 PMIt is superior ... in that it doesn't allow for multilineThat sounds pretty inferior to me
Hullaballoonatic
07/12/2019, 8:58 PMxenoterracide
07/12/2019, 9:22 PMgildor
07/13/2019, 3:10 AM