I want to check whether any item from the array is part of a string. Something like .include?
I wrote a function for that but I am sure there would be a simpler way.
Could someone suggest how I use less code to achieve the same?
$goes_into_cron_comments=["Edumate_upgrade","login"].map!{|item| item.downcase}
params={}
params['run']="login_ldap"
def contains(array,string)
array.each{|item|
if string.include?(string)
return true
end
}
return false
end
#if ($goes_into_cron_comments.include?(params['run'].downcase)) #original condition
if (contains($goes_into_cron_comments,params['run'].downcase))
puts "contains"
else
puts "doesn't contain"
end