Comments (8)
Is for (item in items)
guaranteed to be in order? Even if that's the case, I'm somewhat wary because it's not always true in other languages. I'd rather have code that doesn't require remembering how something behaves.
so probably using Std.downcast is better in this case.
Just to be sure that I fully understand, can you post an actual code example of the change that you're suggesting?
from feathersui-openfl.
Is
for (item in items)
guaranteed to be in order? Even if that's the case, I'm somewhat wary because it's not always true in other languages. I'd rather have code that doesn't require remembering how something behaves.
Ordering depends on a collection/iterator, and since Array is an ordered collection, of course it's guaranteed to be in order. I think that's the same for every language that supports "declarative" for
.
can you post an actual code example of the change that you're suggesting
Something like:
var layoutObject = Std.downcast(item, ILayoutObject);
if (layoutObject != null && !layoutObject.includeInLayout) {
continue;
}
from feathersui-openfl.
Is
for (item in items)
guaranteed to be in order? Even if that's the case, I'm somewhat wary because it's not always true in other languages.
Huh? In what language is this not the case?
from feathersui-openfl.
JS/AS would come to my mind, because there it means key iteration. But for/of
(which is the actual counterpart to Haxe's for/in
) is indeed well defined for arrays.
from feathersui-openfl.
JS/AS would come to my mind, because there it means key iteration.
AFAIK the order of "keys" for Array is still defined there.
from feathersui-openfl.
AFAIK the order of "keys" for Array is still defined there.
Sorry to disappoint, but I have bad news for you:
There is no guarantee that
for...in
will return the indexes in any particular order. - MDN
IIRC AS2 would rather consistently give the array keys to you in reverse order ¯\_(ツ)_/¯
from feathersui-openfl.
IIRC AS2 would rather consistently give the array keys to you in reverse order ¯_(ツ)_/¯
LOL, but oh well, as you already mentioned, Haxe for
is different and more properly "maps" to ES6 for/of loops, or e.g. C# for each, so one should not be afraid to use it and it has better expressiveness.
from feathersui-openfl.
@nadako Unfortunately, this code that you suggested does not work:
var layoutObject = Std.downcast(item, ILayoutObject);
if (layoutObject != null && !layoutObject.includeInLayout) {
continue;
}
Compiler error:
Constraint check failure for downcast. feathers.layout.ILayoutObject should be openfl.display.DisplayObject
from feathersui-openfl.
Related Issues (20)
- Copy/Paste in TextInput not works reliably HOT 4
- TextInput, TextArea: add missing factory for error callout
- BaseScrollContainer: ignore arrow keys, page up/down, and home/end when TextField of type INPUT has focus
- ListViewEvent.ITEM_TRIGGER return as `null` to handler method when used with GroupListView HOT 6
- TextInput content can copied when displayAsPassword=true HOT 2
- TextInput: Add new property to allow prompt to float above input text when focused
- ValidatingSprite using map instead of flags HOT 3
- Only the first row is rendered in `GridView` in a specific configuration.
- GridView: skin property for region to the right of headers and above scroll bar
- AssetLoader: property to display BitmapData and/or an arbitrary DisplayObject instead of loading with a string
- ToggleSwitch: optional on and off text
- Exception: Null Object Reference - Rectangle.hx HOT 5
- Exception: Null Object Reference - Clicking on Button HOT 9
- ItemRenderer: option to disable mouse/touch states
- ListView: scroll selected item fully into view if it is clicked/tapped
- Alert: optional close button in header
- New Component: Window/dialog: Similar to Alert, but allows completely custom content
- Inline Label cutting off in AIR HOT 2
- Fade in throwing reference error HOT 2
- HorizontalAlign.JUSTIFY not working in AIR HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feathersui-openfl.