From: Fuad Saud Date: 2014-01-02T20:21:39-08:00 Subject: [ruby-core:59495] Re: [ruby-trunk - Feature #9347][Open] Accept non callable argument to detect ------Nodemailer-0.5.0-?=_1-1388722899459 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I think, if it was possible, a call like this `ary.detect(:sym)` would make= more sense by using case equality for comparison instead of #call. It = would be useful with regexes for example. There's a ticket proposing this = but I can't seem to find it.=E2=80=94 Sent from Mailbox for iPhone On Thu, Jan 2, 2014 at 8:38 PM, marcandre (Marc-Andre Lafortune) wrote: > Issue #9347 has been reported by marcandre (Marc-Andre Lafortune). > ---------------------------------------- > Feature #9347: Accept non callable argument to detect > https://bugs.ruby-lang.org/issues/9347 > 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=3F > [42].detect(:not=5Ffound){} # =3D> NoMethodError: undefined method = `call' for :not=5Ffound:Symbol > # would return :not=5Ffound instead. > I'd suggest that if the given argument does not `respond=5Fto=3F :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=3F > Inspired by http://stackoverflow.com/questions/20883414/why-does-enumerab= ledetect-need-a-proc-lambda > --=20 > http://bugs.ruby-lang.org/ ------Nodemailer-0.5.0-?=_1-1388722899459 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable I think, if it was possible, a call = like this `ary.detect(:sym)` would make more sense by using case equality = for comparison instead of #call. It would be useful with regexes for = example. There's a ticket proposing this but I can't seem to find it.=
=E2=80=94
Sent from Mailbox for iPhone


On Thu, Jan 2, 2014 at 8:38 PM,= marcandre (Marc-Andre Lafortune) <ruby-co= re@marc-andre.ca> wrote:


Issue #9347 has been reported by = marcandre (Marc-Andre Lafortune).

----------------------------------------
Feature #9347: Accept non callable argument to detect
https://bugs.ruby-lang.org/issues/9347

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=3F

[42].detect(:not=5Ffound){} # =3D> NoMethodError: undefined = method `call' for :not=5Ffound:Symbol
# would return :not=5Ffound instead.

I'd suggest that if the given argument does not `respond=5Fto=3F = :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=3F

Inspired by http://stackoverflow.com/questions/20883414/why-does-en= umerabledetect-need-a-proc-lambda


--=20
http://bugs.ruby-lang.org/

------Nodemailer-0.5.0-?=_1-1388722899459--