Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4616

In Ruby how can I check if a symbol is in an array of symbols? [closed]

$
0
0

Can I do the following? If so how?

I have an array of symbols

symbols = %w{:sym1 :sym2 :sym3} # is this correct implementation?# I'm putting this in a function for this illustrationdef check_symbol(symbol)  symbols.include?(symbol)endputs check_symbol(:sym1) # expect true, but I get falseputs check_symbol(:sym44) # expect false of course

How can I do so I get true on the first puts statement?


Viewing all articles
Browse latest Browse all 4616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>