Is there a way to access dictionary keys in Swift 2 using an index?
var dict = ["item1":1, "item2":2, "item3":3] dict.keys[0]
leads to an error:
15:29: note: overloads for the "index" exist with these partially matching parameter lists: (Base.Index), (range), (Self.Index) print ("key =" + dict.keys [i])
I saw examples from August ( Swift: accessing a dictionary through an index ):
dict.keys.array[0]
At least in Swift 2 there are no array objects on dictionary keys.
In Swift 2, the equivalent dict.keys.arraywould be Array(dict.keys):
dict.keys.array
Array(dict.keys)
let dict = ["item1":1, "item2":2, "item3":3] let firstKey = Array(dict.keys)[0] // "item3"
: , , " " .
, , , / .
Source: https://habr.com/ru/post/1609199/More articles:How to pass subroutine names as arguments in Fortran? - fortranAjax.BeginForm replaces the entire page with a partial view - ajaxCan I confuse an ionic application? if so, how? - angularjshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1609197/how-to-use-inteface-blocks-to-pass-a-function-to-a-subroutine&usg=ALkJrhh9UU5LKTRDT-ZSxnse_YJ5hJ9_uwRemove spaces after insertion with jQuery - jqueryNewtonsoft.Json Causes Visual Studio 2015 Code Analysis Failure - json.netGulp Matter Front + Defeat via Nunjucks - markdownДобавить jQuery для автозаполнения данных в текстовое содержимое вместо их перезаписывания - javascriptInterface mismatch in dummy procedure 'f' when passing function to subroutine - fortranGet a Json array with refinement - jsonAll Articles