Re: Custom type methods (and name)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Custom type methods (and name)
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: 2016年2月19日 08:07:25 -0200
> local cx = complex.new(0, 0)
> local cx2 = complex.new(1, 1)
> print(cx < cx2)
>
> and the mesasge 'attempt to compare two userdata values'
Indeed, my complex library does not set the __lt metamethod since I thought
it made no sense.
If you want better error message, do
complex.__lt=function () error"complex numbers cannot be compared" end