[Swift-devel] Associative array in Swift [GSoC]
Ben Clifford
benc at hawaga.org.uk
Fri Jun 17 17:32:18 CDT 2011
> In which case is the logic following
> logic valid?
> a[0] [ a[0].length + 1 ] = val ;
not really - the array has an unchanging length - you don't know it before
you've finished assigning all the elements into it. [*]
you don't have to use sequential indices: you can assign elements
1,2,3,8,100,101,102 if you like without needing to assign the elements in
between (or, now, strings). if you have some other value associated with
each assignment, for example, the index in an input array, then you can
use that in your output array too rather than inventing a new index. Swift
won't (/shouldn't) get upset by the holes.
[*] that's not strictly true, but the obscure semantics are something
thats probably only of interest to me and hategan as a matter of pedantry.
--
More information about the Swift-devel
mailing list