[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: metamethods... are __gt and __ge missing ?
- From: Tim Hill <drtimhill@...>
- Date: Sun, 22 Sep 2013 12:21:22 -0700
On Sep 22, 2013, at 4:47 AM, Jayanth Acharya <email@example.com> wrote:
> In the list of published metamethods available in every document that I read, I seem to be unable to find __gt and __ge anywhere. Are those really no present, or am I missing something (like checking the right place, doc) ?
> If those are really absent, then does it mean we cannot use metatables to support the > and >= operators for say table comparison ?
Short answer, Lua rewrites > and >= at compile time so that it uses < and <=. So if you implement __lt and __le then you will cover all the possibilities. In fact __le is optional as well, if you don't have one Lua will use __lt by assuming (a <= b) is the same as not (b < a).