
Sept. 7, 2009
7:22 a.m.
Greg Ewing wrote:
Steven D'Aprano wrote:
If you're expecting "exactly one result", then surely it should be an error to receive more than one result? Rather than ask for "any" result and ignoring any unexpected extra items, I think it would be better to have a helper function that verifies you have got exactly one result.
Yes, that could be useful. Maybe call it "one"?
I think "one" fits two of the proposed three use cases pretty nicely. The only remaining use case is where you actually have more than one item but only want any one out of them. But I think in that case you can actually roll your own anyway, as there may be other constrains on exactly how 'equal' all the items are. Stefan