{"id":2902,"date":"2014-09-21T15:56:10","date_gmt":"2014-09-21T19:56:10","guid":{"rendered":"http:\/\/www.acarlstein.com\/?p=2902"},"modified":"2014-09-21T15:56:10","modified_gmt":"2014-09-21T19:56:10","slug":"playing-with-swift","status":"publish","type":"post","link":"http:\/\/blog.acarlstein.com\/?p=2902","title":{"rendered":"Playing with Swift"},"content":{"rendered":"<p>Let say that we have an array of strings:<\/p>\n<p><em><span style=\"color: #339966;\">var cities: [String] = [&#8220;San Francisco&#8221;, &#8220;Denver&#8221;];<\/span><\/em><\/p>\n<p>You can change one string elements of this array given an index.<br \/>\nIn this case we change from &#8220;San Francisco&#8221; to Miami:<\/p>\n<p><em><span style=\"color: #339966;\">cities[0] = &#8220;Miami&#8221;;<\/span><\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Now, let assume we wish to print the last letter of the first string in the array.<\/p>\n<p>This first intent fails:<\/p>\n<p><em><span style=\"color: #339966;\">println(cities[0][advance(cities[0].startIndex, 4)]);<\/span><\/em><\/p>\n<p>This will fail too:<\/p>\n<p><em><span style=\"color: #339966;\">let index = 4;<\/span><\/em><br \/>\n<em><span style=\"color: #339966;\">println(cities[0][index]);<\/span><\/em><\/p>\n<p>&nbsp;<\/p>\n<p>However, this will success:<br \/>\n<em><span style=\"color: #339966;\">println(cities[0][advance(cities[0].startIndex, 4)]);<\/span><\/em><\/p>\n\n<script>\nvar zbPregResult = '0';\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Let say that we have an array of strings: var cities: [String] = [&#8220;San Francisco&#8221;, &#8220;Denver&#8221;]; You can change one string elements of this array given an index. In this case we change from &#8220;San Francisco&#8221; to Miami: cities[0] = &#8220;Miami&#8221;; &nbsp; Now, let assume we wish to print the last letter of the first [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,1261],"tags":[1315,1263,1262],"class_list":["post-2902","post","type-post","status-publish","format-standard","hentry","category-programming","category-swift","tag-ios","tag-os-x","tag-swift-2"],"_links":{"self":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/2902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2902"}],"version-history":[{"count":1,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/2902\/revisions"}],"predecessor-version":[{"id":2903,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/2902\/revisions\/2903"}],"wp:attachment":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2902"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}