3 ms·
You might want a lookup method to usually throw an exception if it doesn't find anything, but sometimes return a user-specified default. It's problematic thoug
by philh 14y ago
You might want a lookup method to usually throw an exception if it doesn't find anything, but sometimes return a user-specified default.
It's problematic though, because writing a thin wrapper becomes a pain in the ass.
- damncabbage 14y agoI'd argue that it's really two functions: * One to do the lookup and potentially explode; this always takes an argument. * A second to provide the default. Have the caller call the appropriate one. User provides params[:search] (or some other "explicitly trying to search"), then call the first. If not, call the latter.