开发者

Flex Associative Array

开发者 https://www.devze.com 2022-12-11 05:02 出处:网络
User inputs a comma separated string and i d like to make a an associative array out of it as follows :

User inputs a comma separated string and i d like to make a an associative array out of it as follows : Input : 4,3,3,2,2 Output : Array{"0"=>4,"1"="3","2"=>3,"3"=>2,"4"=>2}

I can create an array by input.text.spl开发者_如何学Pythonit(",");

But I d like to make it an associative array as above, how to do this?

Thanks.


Well, besides the fact that an array like the one you've got there is already 'associative' -- associated with numbers starting at 0. So:

yourArray[0] // will be 4
yourArray[3] // will be 2

If you want to associate with something else -- like strings -- then you might want to look into the Dictionary class.

0

精彩评论

暂无评论...
验证码 换一张
取 消