Suppose I have an Array: ['a', 'b', 'c']. I want to record whether I have seen a particular array before.
I can put the array in a Set, but that is wasteful if I don't need to store the contents of the array, only that I have seen it before.
In Python, I could hash a tuple (i.e. hash(('a', 'b', 'c'))) and store the result in a set to achieve this. What is the way to do this in Ruby?
hash(('a', 'b', 'c')) in {hash(('a', 'b', 'c'))}. It sounds likeObject#hashis what I'm looking for though - if that's whatSetorHashuse for arrays as keys, then it's good enough for this.O(space). Second: Storing pointers is cheap. Just useSet.