[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: metamethods... are __gt and __ge missing ?
- From: David Demelier <demelier.david@...>
- Date: Sun, 22 Sep 2013 19:40:09 +0200
On 22.09.2013 14:53, Philipp Janda wrote:
> Am 22.09.2013 14:10 schröbte Jayanth Acharya:
>>
>> So, if I understand this correctly, I cannot use the < and <=
>> operators in
>> Lua code while comparing 2 tables say 'a' and 'b', where the intent
>> was to
>> check (a < b). However I could rewrite the Lua code as (b > a). Right ?
>>
>> If so, then this is semantically correct, but makes the code less
>> readable,
>> no ?
>>
> _________________________________________
> | you have | you write | Lua uses |
> |-------------|-----------|--------------|
> | __lt only | a < b | a < b |
> | __lt only | a <= b | not (b < a) |
> | __lt only | a > b | b < a |
> | __lt only | a >= b | not (a < b) |
> | __lt + __le | a < b | a < b |
> | __lt + __le | a <= b | a <= b |
> | __lt + __le | a > b | b < a |
> | __lt + __le | a >= b | b <= a |
> | __le only | a < b | #error# |
> | __le only | a <= b | a <= b |
> | __le only | a > b | #error# |
> | __le only | a >= b | b <= a |
> ------------------------------------------
>
> HTH,
> Philipp
>
Awesome, thanks for that very helpful table :)