feat: implement ! operator for all core types with proper truthiness semantics

Add native `!` methods to Null, Object, Num, String, and List classes so that `!` works reliably on any value. Null returns `true`, all other types return `false` since they are considered truthy. Update documentation to describe the operator as returning the logical complement and add comprehensive tests for each type. Also fix the `all` method test to use a truthy string instead of expecting a runtime error.
This commit is contained in:
Bob Nystrom
2015-01-16 05:50:01 +00:00
parent 4676e87ce9
commit d3ea153a31
10 changed files with 57 additions and 21 deletions
+1
View File
@@ -0,0 +1 @@
IO.print(null) // expect: null
+1
View File
@@ -0,0 +1 @@
IO.print(!null) // expect: true
+4
View File
@@ -0,0 +1,4 @@
IO.print(null is Null) // expect: true
IO.print(null is Object) // expect: true
IO.print(null is Bool) // expect: false
IO.print(null.type == Null) // expect: true