Is there a way to create a condition through string manipulation. here is the code where I attempted to pass a string as a condition into include? method.
"hello eveyone in the house".include?(%w('hello' 'world' 'new\ york' 'place').join(" || ").to_s)
An conditional as argument to
include?
is not possible, becauseinclude?
accepts only a string argument.But you can write something like this:
Or you could generate a regexp from your strings: