Swift Typing Speed Test
Swift shares Kotlin's love of the question mark but adds its own vocabulary: `guard let`, trailing closures with `$0`, and string interpolation via `\()`. These drills use the patterns iOS and server-side Swift developers type daily.
Optionals, Closures, and the Backslash-Paren
Swift's optional system puts `?` after types (`String?`) and `!` for force-unwraps, while `guard let name else { }` creates a distinctive keyword rhythm. String interpolation is unique among major languages: `\(name)` uses backslash-parenthesis rather than braces or dollars, requiring a reach combination found nowhere else in programming.
Closure shorthand replaces parameter names with `$0` and `$1`, key paths compress accessors to `\.wpm`, and operator functions pass bare symbols (`sorted(by: >)`). Argument labels put colons inside call sites (`greet(name:)`), and protocol conformance lists chain types after a colon. The result is a language where symbol placement β more than symbol count β is the typing challenge.
Key Drills for Swift:
- Backslash-paren interpolation: `\(value)` is Swift-only syntax. Drill the backslash-to-paren reach until it's native.
- Dollar-digit shorthand: `$0` appears in most closures. Shift-4 then a digit should be one rolling motion.
- Question mark after types: Optionals put `?` at type ends, not expression starts. Build the postfix habit.
Sample Drill: Optionals & Guard
Unwrapping optionals with guard let and nil coalescing.
func greet(_ name: String?) -> String {
guard let name, !name.isEmpty else {
return "Hello, stranger"
}
return "Hello, \(name)!"
}The Symbols That Slow You Down
The keystrokes below are where Swift typing speed is won or lost. Key positions shown for QWERTY β the pattern transfers to any layout, just on different physical keys.
| Symbol | Used For | Keys | How to Drill It |
|---|---|---|---|
| ? | Optional type | Shift+Slash | Postfix on types: `String?`, `Int?`. The question mark ends types β the opposite habit of most languages. |
| ! | Force unwrap | Shift+1 | `user!.name` β deliberate, shifted, and placed at expression ends. |
| \() | Interpolation | Backslash unshifted (above Enter), then ( as Shift+9 | Swift's unique interpolation: backslash-parenthesis. A reach combination found nowhere else. |
| $0 | Closure shorthand | $ as Shift+4, then a digit | `$0`, `$1` β Shift-4-then-digit rolls through every trailing closure. |
| -> | Return arrow | - unshifted, then > as Shift+Period | Every typed signature: `(Int) -> String`. Same gesture as other languages, same need for speed. |
| : | Argument label | Shift+Semicolon | Colons inside call sites: `greet(name:)`. The colon attaches to labels mid-call β unusual placement. |
Common Swift Typing Mistakes
- βUsing brace interpolation out of Kotlin or JS habit β Swift interpolates with backslash-parentheses, and muscle memory fights it.
- βForgetting the postfix `?` on optional declarations β it ends the type, it doesn't prefix an expression.
- βHesitating on `guard let` lines β the keyword rhythm should read as one chunk, not four words.
What's a Good Swift Typing Speed?
Swift types at 25β40 WPM in real code for most developers, with 45+ WPM at 96%+ accuracy being excellent. Backslash-paren interpolation is the single most Swift-specific reach to drill.