S02E13: Calculating score with zip, reduce, and generics in Swift | Professional iOS Engineering Series
In this episode, you'll see how to replace a procedural scoring implementation that relies on a temporary mutable variable with a more functional approach using Swift's zip
and reduce
functions (no mutation!).
Moreover, we extend the scoring function with generics to support any equatable answer type, and we move the scoring business logic from the QuizEngine to the client app, as the scoring logic is application-specific.
Subscribe to our Youtube channel and follow the project's progress on GitHub.