How can I get an empty list instead of null?

Question:

Suppose I have a couple of arrays:

and I get the intersection (empty):

I would expect $c to contain an empty list such that I could do:

but I don’t. I get a $null (which issues an exception when queried for .length). How can I get an empty list back instead?

Answer:

Wrap it in the array constructor:

Source:

How can I get an empty list instead of null? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply