logoalt Hacker News

itishappy • today at 1:30 AM • 1 reply • view on HN

NonEmpty is a type that allows you to distinguish between:

    a = [undefined];
    res = a.pop() // undefined

    a = [];
    res = a.pop() // undefined

Replies

skeledrew • today at 2:41 AM

As a Python person, that 2nd one looks like a bug. Expecting an exception there. Although also Python doesn't have an `undefined`; `None` would have to suffice.