[Swift-devel] Associative arrays: foreach index issue.
Yadu Nand
yadudoc1729 at gmail.com
Fri Jun 24 13:39:03 CDT 2011
Hi,
After discussing with Justin I used java.util.UUIDs as indices for
cases in which we need something close to appending the value
associated with a particular key.
Now, array["key"]["!"] = 1 ; array["key"]["!"] = 2 ;
works alright, except for the part in which we use foreach to retrieve
the values as the index is actually a UUID casted to string.
Justin asked me to propose a way to fix this, including a new
associative array declaration syntax.
1. We may try using a different declaration style to denote non-int
subscripts.
int array [$] [$] ( where $ represents strings )
2. Or simply modify the foreach syntax to accommodate string
indices. Leaving the following style
foreach value, string:index in array["key"] {
// do work
}
I can't think of anything simpler and which makes more meaning.
Please help!
Of the 2 I mentioned above, I think the 2nd method is the easiest
to implement.
--
Thanks and Regards,
Yadu Nand B
More information about the Swift-devel
mailing list