{"id":376,"date":"2019-01-31T11:29:23","date_gmt":"2019-01-31T02:29:23","guid":{"rendered":"http:\/\/trinitas.tech\/?p=376"},"modified":"2019-01-31T11:29:23","modified_gmt":"2019-01-31T02:29:23","slug":"swift%e3%81%a8kotlin%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e5%be%ae%e5%a6%99%e3%81%aa%e5%b7%ae%e7%95%b0","status":"publish","type":"post","link":"https:\/\/trinitas.tech\/en\/2019\/01\/31\/swift%e3%81%a8kotlin%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e5%be%ae%e5%a6%99%e3%81%aa%e5%b7%ae%e7%95%b0\/","title":{"rendered":"Subtle difference between Swift and Kotlin"},"content":{"rendered":"<h1>Subtle difference between Swift and Kotlin<\/h1>\n<p>There are lots of similarity between Swift and Kotlin, so we decided to use them for new cross-platform project in iOS and Android.<\/p>\n<p>When we start the study of them, we soon noticed the subtle and important difference between them.<\/p>\n<ol>\n<li>Assignment can\/cannot be used as condition<br \/>\nIn swift the operation of assignment is an expression thus return true of false. Thus, we can use it as a condition.<\/li>\n<\/ol>\n<p>In swift we often use this when unwrapping optional objects. The similar mechanism in Kotlin is Nullable. We can use it to achieve optional-like behavior. We are going to write this in another article.<\/p>\n<ol start=\"2\">\n<li>Swift let and Kotlin val<br \/>\nSwift let means the object is immutable. On the other hands, Kotlin val means the object is read-only. So, you can change the member variables of the instance which was created as val object <sup id=\"fnref-376-1\"><a href=\"#fn-376-1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>. This difference is annoying.<\/li>\n<\/ol>\n<p>Reflecting this Kotlin has special mutable collection like MutableSet (Set is read-only.)<\/p>\n<p>We have to consider this difference at the design phase of the project.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr \/>\n<ol>\n<li id=\"fn-376-1\" role=\"doc-endnote\">\nProgramming Kotlin, Stephen Samuel, Stefan Bocutiu, 2017 Packt Publishing (p.30)&#160;<a href=\"#fnref-376-1\" class=\"footnote-backref\" role=\"doc-backlink\">&#8617;&#xFE0E;<\/a>\n<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Subtle difference between Swift and Kotlin There are lots of similarity between Swift and Kotlin, so we decide\u2026 <span class=\"read-more\"><a href=\"https:\/\/trinitas.tech\/en\/2019\/01\/31\/swift%e3%81%a8kotlin%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e5%be%ae%e5%a6%99%e3%81%aa%e5%b7%ae%e7%95%b0\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_locale":"en_US","_original_post":"374","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[6,5,30,60],"tags":[86,31,87,61],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p959K1-64","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/posts\/376"}],"collection":[{"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/comments?post=376"}],"version-history":[{"count":1,"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/posts\/376\/revisions"}],"predecessor-version":[{"id":377,"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/posts\/376\/revisions\/377"}],"wp:attachment":[{"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/media?parent=376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/categories?post=376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trinitas.tech\/wp-json\/wp\/v2\/tags?post=376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}