for-each循环AS3:是方向保证? [英] For-Each Loop AS3: Is the direction guaranteed?

查看:100
本文介绍了for-each循环AS3:是方向保证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的阵列,字典的迭代顺序,并在AS3对象类型,为的for-each和for-in循环两种。是哪些因素可以改变这些环式组合迭代顺序?

I would like to know the iteration order for the Array, Dictionary and Object types in AS3, for both the for-each and the for-in loops. Also what factors can change the iteration order of these loop type combinations?

例如我presume,使用一个换旺火上一个数组类型总是从第一个元素到最后一步。对于-每无法在字典中使用这样如何使用for-in循环的顺序确定?

For example I presume that using a for-each on an Array type always move from the first element to the last. For-each cannot be used on a Dictionary so how is the order determined using a for-in loop?

推荐答案

你的意思是为(X的Y)键入for-each循环? AS3的规范指出,对于循环具有相同的语法和语义在ECMA-262第3版和E4X定义。

Do you mean the for (x in y) type of for-each loop? The AS3 specification says that for loops "have the same syntax and semantics as defined in ECMA-262 edition 3 and E4X".

ECMA-262,即枚举的顺序是由对象定义部分12.6.4状态 - 换句话说,这将取决于不管你是通过迭代一个列表,字典,数组等等

ECMA-262, section 12.6.4 state that "the order of enumeration is defined by the object" - in other words, it will depend on whether you're iterating through a list, a dictionary, an array etc.

我会的希望的,对于大多数收藏品会明确说明的枚举顺序(或该命令没有被定义),但我没有检查的文件...

I would hope that the documentation for most collections will explicitly state the enumeration order (or that the order isn't defined) but I haven't checked...

编辑:不幸的是,规范指出,列举的属性的力学[...]依赖于实现。我看不到任何东西在阵列文档指定顺序。这是一个有点不尽人意,说实话:(

Unfortunately the specs state that "the mechanics of enumerating the properties [...] is implementation dependent." I can't see anything in the Array docs to specify ordering. It's a bit unsatisfactory, to be honest :(

这篇关于for-each循环AS3:是方向保证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆