Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Maybe it's easier to imagine
x = [];
, thenx.slice()
. Or even([]).slice
. In all cases, it looks on the instance of the array for theslice
method and, failing to find one, walks the prototype chain until it gets there. Hypothetically less performant but it's a constant time optimization and I think some or most compilers optimize for the autoboxing this involves.I tried that, but the test says
TypeError: Cannot call method 'toArray' of null
at Test.it
at Test.describe
If I use Cons(null, null) I get this error:
TypeError: Cannot call method 'toArray' of undefined
at Test.it
at Test.describe
Based on the link to the algebraic data type documentation, I think Cons.fromArray([]) should return null, but I wasn't positive.
What should Cons.fromArray([]) return?
null
or
new Cons(null, null)
or something else?
This comment is hidden because it contains spoiler information about the solution