Ruby: How can I have a Hash take multiple keys?

Posted by zxcvbnm on Stack Overflow See other posts from Stack Overflow or by zxcvbnm
Published on 2010-04-06T01:04:30Z Indexed on 2010/04/06 1:13 UTC
Read the original article Hit count: 293

Filed under:
|

I'm taking 5 strings (protocol, source IP and port, destination IP and port) and using them to store some values in a hash. The problem is that if the IPs or ports are switched between source and destination, the key is supposed to be the same.

If I was doing this in C#/Java/whatever I'd have to create a new class and overwrite the hashcode()/equals() methods, but that seems error prone from the little I've read about it and I was wondering if there would be a better alternative here.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about hash