-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I'd like to propose either a change to the locate method, or creation of an alternate method. The locate method throws an exception when the operation does not find a suitable match. This seems unnecessary. In general terms, when I perform a search I expect one of two results. I either find what I'm looking for, or I don't. Neither of these is an unexpected case, but the latter is treated as such when locate throws the ElementNotFound exception.
If my own code is wrapping up locate into a more complex find strategy, having to handle "not found" exceptions adds a whole lot of extra work. If my search strategy is building an array of results, I can easily handle returns of nil or [] with methods such as Array#compact and Array#concat. Forcing me to handle ElementNotFound exceptions requires me to either introduce a rescue block, or bury ALL exceptions with a "rescue nil". Neither exception handling case is desired.