neverthrow icon indicating copy to clipboard operation
neverthrow copied to clipboard

docs: fix `Result.map` example in README.md

Open rivea0 opened this issue 1 month ago • 1 comments

Fixes #631.

With the previous example:

(arr: Array<string>) => arr.map(parseInt)

parseInt gets the indices as its second parameter for the base.

Providing a callback where we pass the item gets rid of the issue:

(arr: Array<string>) => arr.map((s) => parseInt(s))

The base now defaults to 10.

To be even more explicit, we could have also added the second argument to parseInt as well, and maybe a comment to explain it:

// Parse the number as base-10
(arr: Array<string>) => arr.map((s) => parseInt(s, 10))

I think the first option is sufficient, but I can make changes to the PR if needed.

rivea0 avatar Nov 11 '25 16:11 rivea0