Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AGK2. Tier1: Array.find() BUG

Author
Message
Engineer
9
Years of Service
User Offline
Joined: 16th Jul 2014
Location:
Posted: 23rd Jan 2015 16:14
hi all
I program a small tabular database on AGK2.
In the database the first line item - a unique name (string)
To add a new element I enter his name and to verify whether such method Array.find name (name).
There are cases wherein, when checking the existing name, the method returns -1 FIND - not found. At the same time I can see with my own eyes that there is an element. A little tough to make sure I understood that the method does not work well FIND.
upsetting

AGK 2 !
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 23rd Jan 2015 16:42
It is a bit daft ; from the documentation :

".sort() will always sort in ascending order and .find(item) will only work on arrays that are in ascending order."


I do not know if it is doing (say) a binary search, probably something like that.

There are a few handy things that would be fairly easy and would be useful - string find and replace and a find that just did a boring old sequential search would be one of them.
Engineer
9
Years of Service
User Offline
Joined: 16th Jul 2014
Location:
Posted: 23rd Jan 2015 17:14
Oh, damn, I missed. So (after sorting) seems to work ...
It seems they (AGK team) immediately made an optimized search ..

AGK 2 !

Login to post a reply

Server time is: 2024-05-05 06:26:17
Your offset time is: 2024-05-05 06:26:17