```foo if (condition)``` syntax, like exists in Ru...
# language-proposals
Copy code
foo if (condition)
syntax, like exists in Ruby and other languages. It is superior to
Copy code
if (condition) foo
in that it doesn't allow for multiline, and avoids the problem of:
Copy code
if (foo)
    baz // not in scope
Also maybe drop the condition's enclosing
What’s wrong with
foo.takeIf { condition }
? 🤔
i guess I just like the beauty of the syntax
- The existing syntax is consistent with normal
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:
Copy code
fun someName(action:()->Unit):Boolean{}
val someName = true
if someName {}
righto. i think i'd like to have the need for parentheses to be tied to ambiguity, similar to type inferences, but I totally jive with the point about syntax consistency.
It is superior ... in that it doesn't allow for multiline
That sounds pretty inferior to me
meaning that if you want to do multi-line, you'd "have" to use curly braces
I'd like postfix if too, just my opinion that it is sometimes more readable
Do you have an example when it's more readable?