[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: hash metamethod?
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Mon, 2 Feb 2009 02:30:58 +0100
2009/2/1 Joshua Haberman <firstname.lastname@example.org>:
> Languages like Ruby, Python, etc. allow you to define hash functions that
> apply to your objects. You define a hash function and a comparison
> function, and this lets user-defined types be keys in hash tables based on
> their values.
> In any case, like I said I'm mainly wondering if anyone has a PowerPatch,
> I'm not going to argue that it should go into the main Lua (though I
> wouldn't mind that either :)
You don't need a power-patch, with the help of existing metamethods,
you can implement your own hashing algorithm. Here is an example: