Ruby - Help with select method

Rofellos's Avatar, Join Date: Dec 2010
Light Poster
Hi,

I have a problem in Ruby that I can't solve, I already tried to google it, but nothing.

I hava an array. I want to use the select method to select tthe elements that contains the string "YES" or the string "NO".

It doesn't work:

a.select { |x| x.include? "YES" || x.include? "NO" }

Can anyone help me?

Thanks!
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
This works :-)

Code: Ruby
#!/usr/bin/ruby

a = ["Pradeep","Yes","YES","NO"]

print a.select { |x| x.include?("YES") || x.include?("NO") }
shabbir like this
0
Rofellos's Avatar, Join Date: Dec 2010
Light Poster
Thank you, it works!

It works only with the '(' and ')', and without the white space after 'include?'.