Is there a straightforward way to do something like the following without excessive looping?
myArray = [["a","b"],["c","d"],["e","f"]]
if myArray.includes?("c")
...
I know this works fine if it's just a normal array of chars... but I would like something equally as elegant for an array of an array of chars (bonus points for helping convert this to an array of tuples).
myArrayare of the same size, you could write,require 'array'; m = Matrix[*myArray]; m.index("f") #=> [2,1]; m.index("g") #=> nil,[2,1]being truthy.myArraywould generally be writtenmy_array. Snake-case is lower-case letters and underscores, and in the case of method names, the last character can be"?"or"!". You don't have to adopt that convention, but 99%+ of Rubiests do.