Re: [Vim 9 script] Is there a way to get the actual type of an object?

2023-01-15 Thread Lifepillar
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

Re: [Vim 9 script] Is there a way to get the actual type of an object?

2023-01-15 Thread Bram Moolenaar
> 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 >

[Vim 9 script] Is there a way to get the actual type of an object?

2023-01-15 Thread Lifepillar
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