tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/10753-warnings-assignment-within-conditionalRobotlegs: Discussion 2018-10-18T16:35:55Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/326486962014-04-21T23:35:50Z2014-04-22T03:14:54ZWarnings: Assignment within conditional<div><p>Okay, I think I understand what is happening.</p>
<p>I was so distracted working backwards from the StageCraweler
error that didn't properly investigate the conditionals.</p>
<p>I now see that the pattern in each of these cases is:</p>
<p><code>while(someObject = someArray.pop())</code></p>
<p>Array.pop() returns the last index and removes it from the
array. The test condition will become false when there are no more
indexes to pop from the array.</p>
<p>So Robotlegs did not use the wrong operator, they were just
being tricky. I have refactored my Robotlegs source just to avoid
the warnings, but at least I know now that they were
intentional.</p>
<p>Here is how I did my refactor.</p>
<pre>
<code>var someObject:Object;
while (someArray.length > 0)
{
someObject = someArray.pop();
//
}</code>
</pre></div>dedorristag:robotlegs.tenderapp.com,2009-10-18:Comment/326486962014-06-23T15:51:10Z2014-06-23T15:51:11ZWarnings: Assignment within conditional<div><p>I was setting up a new Robotlegs project in FlashDevelop on a
different computer and I ran into these warnings again. This time I
used a different refactoring that keeps the intention of the code
the same, but suppresses the warning.</p>
<pre>
<code>while ((someObject = someArray.pop()) != null)
{
//
}</code>
</pre></div>dedorris