On 2023-01-15, Bram Moolenaar wrote:
>> Is there a way to distinguish the class of the value returned by
>> [a function]?
>
> Currently not. I have been wondering what would be the best way to
> cover this. We already have type(), but this only returns the basic
> type. For example for list
> Silly example:
>
> vim9script
>
> class Num
> this.n = 0
> endclass
>
> class Even extends Num
> def new(this.n)
> if this.n % 2 == 1
> throw 'Not even'
> endif
> enddef
>
> def IsPrime(): bool
> return this.n == 2
>
Silly example:
vim9script
class Num
this.n = 0
endclass
class Even extends Num
def new(this.n)
if this.n % 2 == 1
throw 'Not even'
endif
enddef
def IsPrime(): bool
return this.n == 2
enddef
endclass
class