One of the many possible ways of iterating over an array in Flex is:
1 2 3 4 5 | private function iterateOverArray(arr : Array) : void { for(var i : int = 0; i < arr.length; i++){ doSomethingWith(arr[i]); } } |
But this code will cause problems if the Array is null, to avoid this kind of problems you can use the following code instead:
1 2 3 4 5 | private function iterateOverArray(arr : Array) : void { for each(var o : Object in arr){ doSomethingWith(o); } } |
This way we do not need two variable declarations, and we do not try to read the length of a possible null variable.
If you enjoyed this post, make sure you subscribe to my RSS feed!
Many of you will probably not agree with me, but if you read all this post, you will probably agree that commenting your source code is a sign that [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
As you can see here, Adobe created a big problem (at least for me) after solving a memory leak problem.
But thanks to Scott Melby at this post, now I [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
Tags: bug, flex, workaround
I have worked with C++ in my early days of programming (between 1997 and 2000), but I used to work with Borland C++ Builder and Microsoft Visual C++, in [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
I have published some time ago a GEdit plugin for formatting Ruby code.
Now I just updated the plugin and added support for formatting html.erb and .xml.erb files too.
The main [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
AutoTest (part of ZenTest suite) is a very useful tool when you are working with Ruby On Rails development, but I always had problems configuring cool notifications for [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
I work with Java for a long time, and I’m used to Eclipse facilities, but to work with ruby on rails I think an IDE is not needed, I [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
First of all, this is not my code, this is just a backport of a Rails EDGE feature to work with Rails 2.0.2 …
I searched through Rails code and [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
I have been using this little plugin I wrote for some time now.
The main idea is that I always start working in the migrations, and there I define: not [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
Have you ever read about easyb? and about Grails? May be you answer yes to one or both previous questions, but this is the first time you will find [...] Continue Reading…
If you enjoyed this post, make sure you subscribe to my RSS feed!
Tags: easyb, easyb-test, grails, petproject, plugin, test