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

find vs findall vs tryfind #12

Open
melcher opened this issue Oct 21, 2014 · 1 comment
Open

find vs findall vs tryfind #12

melcher opened this issue Oct 21, 2014 · 1 comment

Comments

@melcher
Copy link
Member

melcher commented Oct 21, 2014

Proposed functionality for find/findAll:

  // Find an element
  // -- throws an exception unless results.length !== 1
  find('string') 

  // Find any/all elements
  // -- finds any number of elements (including 0)
  // -- could be used by the find function
  findAll('string') 

  // Find a specific number of elements
  // -- throws an exception unless results.length == number
  find(3, 'string')
  // alternatively
  find('string', {length: 3})

I believe this would remove the necessity for tryfind, as you could just do a findAll. This loosely borrows it's behavior/syntax from ActiveRecord, where find() will throw an exception or return 1 element and find_all just returns any number of elements and doesn't throw an exception in any case.

@melcher
Copy link
Member Author

melcher commented Oct 21, 2014

@EpiphanyMachine @bwest87 @khempenius thoughts?

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

No branches or pull requests

1 participant