Replies: 1 comment
-
This is intended to be achieved with records. I remember there is existing discussion for this but can't find it.
It's not interesting to add an alternative syntax for the same purpose. In my opinion, the Kotlin syntax is much less readable. The current syntax is easily readable by simply looking at
Actively discussed in #9802. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ideas to Improve the C# Syntax
As a 15y C# developer I was amazed how easily I can forget it and learn new syntax which improves readability and shortens the code. That is the Kotlin syntax. The Java is far from my favorite, but the Kotlin is like evolution of C#.
Here are some ideas:
Primary Constructors with Auto Properties
should be equivalent of
The optional
readonlymodifier can introduce property with the getter only.Benefits
Custom DSL syntax support
When a delegate (Action<> or Funct<>) is the last parameter of a method, the call can be simplified to move the delegate out of brackets. If the delegate is the only parameter, then even omit the brackets entirely.
A method:
Usage:
Without it:
And in addition if there is
thismodifier, it allows to write inline extensions:And now the usage:
Benefits
usingwith very similar syntax;can be omitted to have experience likeusingitfor the first lambda parameter, it shortens the syntax tooShorthand Properties
This
is adequate to the
Benefits
Constants and Static Methods Can be Without Class
is equivalent to the
usage:
or
Benefits
Beta Was this translation helpful? Give feedback.
All reactions