Object#in? also accepts multiple parameters #3767

merged 1 commit into from Nov 27, 2011


None yet
4 participants

tadast commented Nov 26, 2011

This is just a suggestion, but since the change is quite simple, I've created a pull request. The idea is to allow passing multiple arguments to Object#in? method, like:

animal = "cat"
animal.in?("dog", "cat", "rat")

currently, you'd have to do something like this:

animal = "cat"
animal.in?(["bat", "cat", "rat"])

which is not very nice. Implementation also preserves current behaviour.
Do you think it would be useful?


wycats commented Nov 27, 2011

This was the implementation in Merb. I like it.

wycats added a commit that referenced this pull request Nov 27, 2011

Merge pull request #3767 from tadast/object_in
Object#in? also accepts multiple parameters

@wycats wycats merged commit 3c81fc3 into rails:master Nov 27, 2011


sikachu commented Nov 27, 2011

@wycats I originally propose this varargs version in #258, but I think either @dhh or @tenderlove rejected it.

Does @dhh and @tenderlove feels ok after this get merged in?


fxn commented Nov 27, 2011

@tadast could you please update the AS core extensions guide please? Here http://edgeguides.rubyonrails.org/active_support_core_extensions.html#in


tadast commented Nov 27, 2011


fxn commented Nov 27, 2011

@tadast excellent thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment