It turns out "is" is just a normal overridable operator. Who knew?

This commit is contained in:
Bob Nystrom
2015-11-07 13:00:24 -08:00
parent 931d9ca4d3
commit 7ae9888c4f
5 changed files with 30 additions and 4 deletions

View File

@ -14,6 +14,7 @@ class Foo {
!=(other) { "infix != " + other }
&(other) { "infix & " + other }
|(other) { "infix | " + other }
is(other) { "infix is " + other }
! { "prefix !" }
~ { "prefix ~" }
@ -37,3 +38,4 @@ System.print(foo | "a") // expect: infix | a
System.print(!foo) // expect: prefix !
System.print(~foo) // expect: prefix ~
System.print(-foo) // expect: prefix -
System.print(foo is "a") // expect: infix is a