{"id":23269,"date":"2018-11-01T16:51:57","date_gmt":"2018-11-01T20:51:57","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=23269"},"modified":"2018-11-01T16:53:19","modified_gmt":"2018-11-01T20:53:19","slug":"swifts-if-case-let-syntax","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/11\/01\/swifts-if-case-let-syntax\/","title":{"rendered":"Swift&rsquo;s &ldquo;if case let&rdquo; Syntax"},"content":{"rendered":"<p><a href=\"http:\/\/fuckingifcaseletsyntax.com\">Zoe Smith<\/a> (via <a href=\"https:\/\/twitter.com\/jimcorreia\/status\/1057464767709761536\">Jim Correia<\/a>):<\/p>\n<blockquote cite=\"http:\/\/fuckingifcaseletsyntax.com\"><p><code>case let<\/code> immediately precedes the candidate pattern in both versions. However, when using <code>if case let<\/code> the value comes after the <code>=<\/code> operator<\/p>\n<p>[&#8230;]<\/p>\n<p><code>case let<\/code> is a shortcut so all subsequent associated values can be bound just by providing variable names.<\/p>\n<p>[&#8230;]<\/p>\n<p>Add conditions to <code>if<\/code> and <code>guard<\/code> using commas<\/p>\n<p>[&#8230;]<\/p>\n<p>Iterate using <code>for<\/code>, <code>where<\/code> and logical operators<\/p><\/blockquote>\n\n<p>See also: <a href=\"http:\/\/fuckingclosuresyntax.com\">Swift Closures<\/a> and <a href=\"http:\/\/fuckingblocksyntax.com\">Objective-C Blocks<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Zoe Smith (via Jim Correia): case let immediately precedes the candidate pattern in both versions. However, when using if case let the value comes after the = operator [&#8230;] case let is a shortcut so all subsequent associated values can be bound just by providing variable names. [&#8230;] Add conditions to if and guard using [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2018-11-01T20:51:59Z","apple_news_api_id":"c983d0d9-139c-4e3f-a6dd-0ab45f01fe7c","apple_news_api_modified_at":"2018-11-01T20:53:21Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AyYPQ2ROcTj-m3Qq0XwH-fA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[46,71,901],"class_list":["post-23269","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/23269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=23269"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/23269\/revisions"}],"predecessor-version":[{"id":23277,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/23269\/revisions\/23277"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=23269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=23269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=23269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}