{"id":16277,"date":"2016-11-06T12:04:54","date_gmt":"2016-11-06T17:04:54","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=16277"},"modified":"2016-11-06T12:04:54","modified_gmt":"2016-11-06T17:04:54","slug":"underscore-uses-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/11\/06\/underscore-uses-in-swift\/","title":{"rendered":"Underscore Uses in Swift"},"content":{"rendered":"<p><a href=\"https:\/\/rainsoft.io\/useful-details-about-underscore-keyword-in-swift\/\">Dmitri Pavlutin<\/a> (via <a href=\"https:\/\/swiftnews.curated.co\/issues\/108?\">Natasha Murashev<\/a>):<\/p>\n<blockquote cite=\"https:\/\/rainsoft.io\/useful-details-about-underscore-keyword-in-swift\/\">\n<p>You can use <code>_<\/code> to suppress the argument label every time its indication seems redundant.<\/p>\n<p>[&#8230;]<\/p>\n<p><code>let (_, sub, _, div)<\/code> contains <code>_<\/code> at first and third positions. This indicates that addition and multiplication results are insignificant.<\/p>\n<p>[&#8230;]<\/p>\n<p>The flight speed case <code>.flight(let speed, _)<\/code> omits the information about the altitude using an underscore <code>_<\/code>. Extracting the altitude in this case is simply not necessary.<\/p>\n<p>[&#8230;]<\/p>\n<p>Otherwise you can discard the result using an underscore [&#8230;] Such way you let know the compiler that you ignore the returned value. And no warning is triggered in this case.<\/p>\n<p>[&#8230;]<\/p>\n<p>If you need to skip naming some closure parameters, just mark those with underscores.<\/p>\n<p>[&#8230;]<\/p>\n<p>Another common usage of the underscore is to iterate a code block a particular number of times, and ignore the iteration value.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Dmitri Pavlutin (via Natasha Murashev): You can use _ to suppress the argument label every time its indication seems redundant. [&#8230;] let (_, sub, _, div) contains _ at first and third positions. This indicates that addition and multiplication results are insignificant. [&#8230;] The flight speed case .flight(let speed, _) omits the information about the [&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":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","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-16277","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\/16277","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=16277"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16277\/revisions"}],"predecessor-version":[{"id":16278,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16277\/revisions\/16278"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=16277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=16277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=16277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}