We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
search
Hi there,
I already saw a few issues which were related to search, but can someone explain this behaviour? I am searching for a string value.
const { collect } = require('collect.js'); const c = collect(['0', '00', '000', '0-0', '0*0', '0&0']); // Collection { items: [ '0', '00', '000', '0-0', '0*0', '0&0' ] } c.search('0', true); // Result: 0 c.search('00', true); // Result: 1 (correct!) c.search('000', true); // Result: 2 c.search('0-0', true); // Result: 3 c.search('0&0', true); // Result: 5 c.search('0&0', true); // Result: 5
Am I doing to something wrong here?
Thanks, Edwin
The text was updated successfully, but these errors were encountered:
This is expected behavior, as per the documentation:
The search method searches the collection for the given value and returns its key if found. If the item is not found, false is returned.
I have also confirmed the same results using Laravel's Collection.
You are using all strings in your collection, so there is no reason to pass true as the second parameter.
true
This issue should be closed.
Sorry, something went wrong.
No branches or pull requests
Hi there,
I already saw a few issues which were related to
search
, but can someone explain this behaviour?I am searching for a string value.
Am I doing to something wrong here?
Thanks,
Edwin
The text was updated successfully, but these errors were encountered: