Page MenuHomeFeedback Tracker

count instead of foreach not works now
Closed, ResolvedPublic

Description

A lot of modes use count instead of foreach, like here: https://community.bistudio.com/wiki/Code_Optimisation#forEach_vs_count

But now count block is required to return boolean, and it breaks a lot of code.

Details

Legacy ID
119087274
Severity
None
Resolution
No Bug
Reproducibility
Always
Category
Scripting
Steps To Reproduce

b = []; {b pushBack _x} count allUnits

Additional Information

works if
b = []; {b pushBack _x; false} count allUnitsUAV

Event Timeline

nkey edited Steps To Reproduce. (Show Details)Oct 14 2014, 11:19 PM
nkey edited Additional Information. (Show Details)
nkey set Category to Scripting.
nkey set Reproducibility to Always.
nkey set Severity to None.
nkey set Resolution to No Bug.
nkey set Legacy ID to 119087274.May 7 2016, 7:36 PM

It is not the count. pushBack has been expanded and returns the index of last element inserted, which is Number, and count expects either Nothing or Boolean.

b = []; {0 = b pushBack _x} count allUnits

assigning result of pushBack to 0 will make it return nothing.

nkey added a subscriber: nkey.May 7 2016, 7:36 PM
nkey added a comment.Oct 14 2014, 11:59 PM

OK, now I see.
Thanks for info.

Gundy added a subscriber: Gundy.May 7 2016, 7:36 PM

Thanks KK, I was just stumbling over this one as well...

Mass-closing all resolved issues not updated in the last month.

Please PM me in BI Forums (http://forums.bistudio.com/member.php?55374-Fireball) if you feel your bug was closed in error.