Skip to content

Commit

Permalink
Correct indentation in multi-line switch case (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jager-yoo authored Mar 7, 2024
1 parent 4f369f6 commit 0f14982
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1320,45 +1320,45 @@ _You can enable the following settings in Xcode by running [this script](resourc
func handle(_ action: SpaceshipAction) {
switch action {
case .engageWarpDrive:
warpDrive.engage()
warpDrive.engage()
case .enableArtificialGravity:
artificialGravityEngine.enable(strength: .oneG)
artificialGravityEngine.enable(strength: .oneG)
case .scanPlanet(let planet):
scanner.scan(planet)
scanner.scan(planet)
case .handleIncomingEnergyBlast:
energyShields.engage()
energyShields.engage()
}
}

// ALSO RIGHT. Blank lines are still permitted after single-line switch cases if it helps with readability.
func handle(_ action: SpaceshipAction) {
switch action {
case .engageWarpDrive:
warpDrive.engage()
warpDrive.engage()

case .enableArtificialGravity:
artificialGravityEngine.enable(strength: .oneG)
artificialGravityEngine.enable(strength: .oneG)

case .scanPlanet(let planet):
scanner.scan(planet)
scanner.scan(planet)

case .handleIncomingEnergyBlast:
energyShields.engage()
energyShields.engage()
}
}

// WRONG. While it's fine to use blank lines to separate cases, spacing within a single switch statement should be consistent.
func handle(_ action: SpaceshipAction) {
switch action {
case .engageWarpDrive:
warpDrive.engage()
warpDrive.engage()
case .enableArtificialGravity:
artificialGravityEngine.enable(strength: .oneG)
artificialGravityEngine.enable(strength: .oneG)
case .scanPlanet(let planet):
scanner.scan(planet)
scanner.scan(planet)

case .handleIncomingEnergyBlast:
energyShields.engage()
energyShields.engage()
}
}
```
Expand Down

0 comments on commit 0f14982

Please sign in to comment.