Swift Quiz
Each quiz is a short Swift program with a surprising twist. Predict what it does, then read the explanation.
- #1 ★★★ Tuple Element Swap
- #2 ★★★ Optional Default Precedence
- #3 ★★★ Task Cancellation and async let
- #4 ★★★ discard self
- #5 ★★★ consuming on a Copyable Struct
- #6 ★★★ Existential Self Requirement
- #7 ★★★ Function Subtyping
- #8 ★★★ Typed Throws in Closures
- #9 ★★★ Optional-Chained Mutation on a Dictionary
- #10 ★★★ Witness vs Extension Dispatch
- #11 ★★★ Protocol Defaults Through Class Inheritance
- #12 ★★★ Diamond Default
- #13 ★★★ Conditional Default
- #14 ★★★ Re-stated Protocol Requirement
- #15 ★★★ Constrained Extension and Generic Context
- #16 ★★★ Conditional Consume
- #17 ★★★ @dynamicMemberLookup Over a Private Field
- #18 ★★★ Dynamic Member Lookup Priority
- #19 ★★★ Overload Resolution in a Generic Context
- #20 ★★★ Nested Closure Weak Self