SAM Style Curly-Brace Quirk

I’m with you. Hiding braces on the end of the line is an abomination and have no idea how anyone ever thought this was a good idea. This crops up in other cases as well, such as higher order functions that have a single parameter that is a function and the ability to drop the parentheses.

 value.apply
 {
     doSomething()
 } 

does not compile, but does if you hide the opening brace on the end of the line. I have taken to doing this instead, but then you get a warning about unnecessary parentheses:

 value.apply()
 {
     doSomething()
 } 

So unlike Jonathan, I do not recommend you make your code harder to read to work around the fact that the compiler is broken, I want to see the compiler quit advocating the less readable style.

Can you tell that I this is a hot button issue with me?

Some other links on the topic:

https://youtrack.jetbrains.com/issue/KT-15195

1 Like