Y
Hacker News
new
|
ask
|
show
|
jobs
by
throwaway09432
1191 days ago
Can you map over this and preserve the NonEmptyArray type?
1 comments
triyambakam
1190 days ago
Do you mean pass in a type?
type NonEmptyArray<T> = [T, ...T[]];
link
throwaway09432
1190 days ago
I mean if I have a NonEmptyArray say xs, and I then xs.map(x=>2*x), will the result of this expression be a NonEmptyArray ?
link
triyambakam
1187 days ago
No, unfortunately it will just be number[] as the return type.
link