I have an array of strings:
string_array = ['memberid', 'membershiptype', 'date']
Now I need to check whether or not this array contains 'id', and I want it to return true.
I know I can do string_array.include? 'memberid', but I need to find a substring within that string of 'id'.
string_array.any? { |e| e.include? 'id' }
any? returns true if any of the elements in the array are true for the given predicate (i.e. the block passed to any?)
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