[vim9script] How to compare two objects for identity vs equality?

53 views
Skip to first unread message

Lifepillar

unread,
Jul 23, 2023, 2:24:08 PM7/23/23
to vim...@googlegroups.com
The following test passes:

```vim
vim9script

class C
endclass

def Test_ObjectEquality()
var o1 = C.new()
var o2 = C.new()

assert_true(o1 == o2)
enddef

v:errors = []
Test_ObjectEquality()
echo v:errors
```

Fine, == is value-based equality. Is there a way to compare for
identity, that is, so that o1 and o2 are considered two different
instances?

Thanks,
Life.



Lifepillar

unread,
Jul 23, 2023, 2:30:22 PM7/23/23
to vim...@googlegroups.com
On 2023-07-23, Lifepillar <lifep...@lifepillar.me> wrote:
> Fine, == is value-based equality. Is there a way to compare for
> identity, that is, so that o1 and o2 are considered two different
> instances?

Aaah, never mind, there are `is` and `isnot`. Time to find a cool place
to avoid brain melting, I guess...

Life.

Reply all
Reply to author
Forward
0 new messages