RCR: String#contain? and Array#contain?

R

Roger Pack

Every time I have to guess from memory whether to use "contain?" or
"include?" within arrays and strings, I always guess wrong (the right
answer is only "include?" BTW).
Since ruby typically allows multiple ways of doing things, consider this
a feature request to add contain? to both String and Array.

Any feedbacks to this idea?
Thanks.
-r
 
I

Intransition

Every time I have to guess from memory whether to use "contain?" or
"include?" within arrays and strings, I always guess wrong (the right
answer is only "include?" BTW).
Since ruby typically allows multiple ways of doing things, consider this
a feature request to add contain? to both String and Array.

Any feedbacks to this idea?

alias :contain?, :include?

That's what you mean?
 
B

Benoit Daloze

Every time I have to guess from memory whether to use "contain?" or
"include?" within arrays and strings, I always guess wrong (the right
answer is only "include?" BTW).
Since ruby typically allows multiple ways of doing things, consider this
a feature request to add contain? to both String and Array.

Any feedbacks to this idea?
Thanks.
-r
--

You might want to read the thread about the "in" operator on ruby-core.
Something like:
e.in? ary
e in ary
give more sense to me than any enum.method? e
 
R

Roger Pack

e in ary
give more sense to me than any enum.method? e

True, though at times I would find it convenient to use the enum method,
like

strin.each_line { |line|
if line.contain? 'abc'
print 'yes'
end
}
alias :contain?, :include?
That's what you mean?

Yep, but just not me having to do it :)

-r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top