Elegant way of turning Dictionary or Generator or Sequence in Swift into an Array? -


is there elegant way convert dictionary (or sequence or generator) array. know can convert looping through sequence follows.

var d = ["foo" : 1, "bar" : 2] var g: dictionarygenerator<string, int> = d.generate()  var = array<(string, int)>()  while let item = g.next() {     += item } 

i hoping there similar python's easy conversion:

>>> q = range(10) >>> = iter(q) >>> <listiterator object @ 0x1082b2090> >>> z = list(i) >>> z [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>>  

the + operator array accept sequence, can write

var d = ["foo" : 1, "bar" : 2] var = [] + d 

i don't think similar possible generators though


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -