I am basically looking for a prettier way to write:
do_something() if my_string == 'first' | my_string == 'second' | my_string == 'third'
Any ideas?
The most common solution is to use Array#include?:
do_something if %w(first second third).include? my_string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With