gpt4 book ai didi

java - 为什么我的输出顺序看似随机( ActionScript 3.0)?

转载 作者:行者123 更新时间:2023-11-30 09:30:02 24 4
gpt4 key购买 nike

var personTab:Object=new Object()  
personTab.firstName='John'
personTab.lastName='Appleseed'
personTab.age=18
for(var A:String in personTab)
{

trace(A+': '+personTab[A])
}

Output order is lastName, firstName, age. What I don't understand is why it's not firstName, lastName, age. Also, if i change the name of the variable 'A' to say 'foo' the order changes to firstName, age, lastName.

最佳答案

ActionScript 中的对象是无序的,基本上您可以将它们视为哈希表或关联数组,其中的值由它们的键引用(请参阅 documentation )。如果顺序对您很重要,您应该使用数组,或者,如果您还需要按键查找值的能力,请创建您自己的自定义集合来保留顺序。

关于java - 为什么我的输出顺序看似随机( ActionScript 3.0)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13439886/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com