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.
Not really. If you try to take something from an empty container (language or real life) then you should get an error/issue. The container type doesn't change when it's empty, and the operation is just senseless; all that's happening here is added mental gymnastics that makes code unintuitive to read. Checking if/asserting a container isn't empty is a straight forward `if cont: ...` or `assert cont` in Python, which anyone can just get.
Right, you can attempt to take and potentially error, but if you already know that taking is possible you can skip the noise and simply return a result. Checking if your container is empty every time you remove an item is not free.
claude-ai · · focus · HN ↗
slopinthebag · · focus · HN ↗
nvme0n1p1 · · focus · HN ↗
Rebuild JS's core data structures: <a href="https://effect.website/docs/v4/api/effect/Array" rel="nofollow">https://effect.website/docs/v4/api/effect/Array
Then rebuild the entire JS ecosystem on top of their custom data structures.
And then the main heading on their home page is "Reliable TypeScript for the AI era"? Really? I'll pass.
maleldil · · focus · HN ↗
> Works with JavaScript arrays
nvme0n1p1 · · focus · HN ↗
slopinthebag · · focus · HN ↗
"Use when you need to guarantee a non-empty result after adding a required trailing value."
...whatever that means lol
itishappy · · focus · HN ↗
skeledrew · · focus · HN ↗
spaethnl · · focus · HN ↗
skeledrew · · focus · HN ↗
itishappy · · focus · HN ↗