feature: last should allow set
tjmehta opened this issue · 1 comments
tjmehta commented
last(arr, key, val)
stoeffel commented
I would prefer to keep last
simple.
You could use lens
for that.
var lens = require('101/lens');
var last = require('101/last');
var lastLens = lens(
last,
function(val, arr) {
var clone = arr.slice();
clone[arr.length-1] = val;
return clone;
}
);
lastLens([1, 2, 3, 4]); // => 4
lastLens.set(6, [1, 2, 3, 4]); // => [1, 2, 3, 6]
Or a new function setLast
?