Enum "shorter dot" syntax sugar #1183
Labels
feature
Proposed language feature that solves one or more problems
state-duplicate
This issue or pull request already exists
Hello there! 🖖
I've found the explicitly specifying an enum's name is too boilerplate. So can u please add "shorter dot" syntax sugar?
Example:
var directionToHead = CompassPoint.west
The type ofdirectionToHead
is inferred when it’s initialized with one of the possible values of CompassPoint. OncedirectionToHead
is declared as aCompassPoint
, you can set it to a differentCompassPoint
value using a shorter dot syntax:directionToHead = .east
The type ofdirectionToHead
is already known, and so you can drop the type when setting its value. This makes for highly readable code when working with explicitly typed enumeration values.if directionToHead == .east { doSomething() }
The text was updated successfully, but these errors were encountered: