Lecture 4: Grid + enum + Optionals

The fourth video lecture given to Stanford students in Spring quarter of 2020 continues the Memorize demo by enhancing significantly the arrangement of the cards by creating our own container View called Grid (which also involves a number of basic functional programming concepts). Two more important Swift language features are discussed (enum and Optionals). And we finally get Memorize playing the card matching game itself (prominently featuring Optionals in our implementation).

The survey of the Swift type system completes with a discussion of enum, a data structure with more functionality built into it than students are used to from other languages. While the reading assignments in this course are the primary way students learned the Swift language, occasionally a very important feature of the language is highlighted in lecture, as in this lecture where Optionals are explained in detail and then extensively demonstrated as we use them prominently in our implementation of the full game logic for Memorize in our Model.


Leave a Comment

We don't require your email address, or your name, for anyone to leave a comment. If you do add an email address, you may be notified if there are replies to your comment - we won't use it for any other purpose. Please make respectful comments, which add value, and avoid personal attacks on others. Links are not allowed in comments - 99% of spam comments, attempt to post links. Please describe where people may find additional information - for example "visit the UN website" or "search Google for..." rather than posting a link. Comments failing to adhere to these guidelines will not be published.