For example I have an array ['15, Balloons', '1, Onions', '18, Soap']
How do I check if the word "Soap" is in any of the options, ignoring the other value ("18," in this case)?
I've tried using include?
but include?
only returns boolean if the whole 18, Soap
is there
CodePudding user response:
let's check if any of the array's items include Soap
soap_present = arr.any? { |item| item.include?('Soap') }