From: "matz (Yukihiro Matsumoto)" Date: 2014-01-03T11:38:08+09:00 Subject: [ruby-core:59493] [ruby-trunk - Feature #9347] Accept non callable argument to detect Issue #9347 has been updated by matz (Yukihiro Matsumoto). I am afraid that kind of conditional behavior could error prone (e.g. accidental misbehavior when one forget having #call in argument object). I'd rather have #detect with keyword argument, like ary.detect(ifnone: :notfound). Matz. ---------------------------------------- Feature #9347: Accept non callable argument to detect https://bugs.ruby-lang.org/issues/9347#change-44041 Author: marcandre (Marc-Andre Lafortune) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: current: 2.2.0 Currently, the only argument that `Enumerable#detect` accepts is a callable object. Shouldn't we accept non callable objects too? [42].detect(:not_found){} # => NoMethodError: undefined method `call' for :not_found:Symbol # would return :not_found instead. I'd suggest that if the given argument does not `respond_to? :call`, then it would be returned as is instead of raising an error as currently. Wouldn't this be more flexible and possibly more performant? Inspired by http://stackoverflow.com/questions/20883414/why-does-enumerabledetect-need-a-proc-lambda -- http://bugs.ruby-lang.org/