Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return index with functional's "find" functions #33

Open
LJNIC opened this issue Sep 15, 2021 · 1 comment
Open

Return index with functional's "find" functions #33

LJNIC opened this issue Sep 15, 2021 · 1 comment

Comments

@LJNIC
Copy link

LJNIC commented Sep 15, 2021

It would be nice if the find family of functions also gave the index into the table.

@1bardesign
Copy link
Owner

Sorry for missing this for so long!

We could, but I'm actually looking at going the other way in terms of the functional api, and removing the often-superfluous index values and providing a _with_index version of functions that changed (eg map and map_with_index) - find_match_with_index could work too, or just find_match_index that just returns the index.

At present - unless you're on a very big collection - the likely anonymous function declaration each time find is used will be more expensive than the O(N) search for table.index_of to get the index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants