~/devtype

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.

LV 1
Level 0 / 100 XP
Best 0 WPM
main.js
00 wpm
00%
0s
1
Just start typing or click the code
Esc restart Enter new line, indentation is skipped for you

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.

swift-optional · easy
func greet(_ name: String?) -> String {
    guard let name, !name.isEmpty else {
        return "Hello, stranger"
    }
    return "Hello, \(name)!"
}

All 15 Swift Drills

Every session picks a random drill from this pool. Use the difficulty filter above to stay on easy warm-ups or jump straight to the hard ones.

  • Optionals & Guard easy

    Unwrapping optionals with guard let and nil coalescing.

  • Reduce & Filter Arrays easy

    Sum prices with reduce and pick cheap items with shorthand arguments.

  • Dictionary Defaults easy

    Increment counts with a default subscript and iterate in sorted order.

  • Switch with Ranges easy

    Turn a numeric score into a letter grade using range patterns.

  • Computed Properties easy

    Expose a Fahrenheit view of a Celsius value with get and set.

  • Structs & Protocols medium

    Value types conforming to protocols with computed properties.

  • Codable & CodingKeys medium

    Decode snake_case JSON into a struct with custom coding keys.

  • SwiftUI State View medium

    Drive a simple counter view with @State and a styled button.

  • Throwing Functions medium

    Validate a password with a custom Error enum and do-catch.

  • Collection Extensions medium

    Add an isNotEmpty property and a bounds-safe subscript to Collection.

  • Closures & Higher-Order hard

    Trailing closures with map, filter, and reduce chains.

  • Enums with Associated Values hard

    Match error cases with bound values and where clauses in a switch.

  • Async/Await Networking hard

    Fetch and decode JSON with URLSession and run requests with async let.

  • Actor-isolated Cache hard

    Deduplicate concurrent image loads with an actor and in-flight tasks.

  • Combine Search Pipeline hard

    Debounce a published query and assign search results on the main queue.

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.