Rubyist meets Swift
summary
Compares Ruby idioms to concrete Swift code: shows how Swift handles variables/constants, optionals and the coalescing operator, external vs internal parameter names for keyword-like args, closures as map callbacks, and using extensions to make Ints usable in conditionals. Builds a working dictionary fetch implementation that accepts a key, optional default or default-producing closure and calls fatalError on missing keys (no exceptions in Swift). Notes Swift betas change syntax quickly.
AI-written summary · about
chapters (16)
- 0:00Start
- 2:38variable
- 3:14allows mutation
- 3:30constant
- 4:01prevents mutation
- 4:30type safe
- 5:05type inference
- 7:24optionals?
- 11:29external parameters
- 13:34closures
- 15:49function argument
- 17:52conditional
- 20:01Hash#fetch
- 22:47var dict = ["one" : 1] // Dictionary
- 23:43method params
- 26:49fatalError("Key (key) not found.")








