kyleect / locks

A toy language branched from Lox to learn language implementation and tooling. Forked from loxcraft
https://kyleect.github.io/locks/#/docs
MIT License
0 stars 0 forks source link

Implement instanceof #64

Open kyleect opened 10 months ago

kyleect commented 10 months ago
print "Hello" instanceof String; // out: true
print "Hello" instanceof Number; // out: false

print 123 instanceof Number; // out: true
print 123 instanceof String; // out: false

fn exampleFn () {}

print exampleFn instanceof Function; // out: true

class Example {}

print Example instanceof Function; // out: false

class ChildExample < Example {}

class AnotherExample {}

var instance = ChildExample();

print instance instanceof ChildExample; // out: true
print instance instanceof Example; // out: true
print instance instanceof AnotherExample; // out: false