Open Aaronius opened 6 years ago
I totally agree! Do you think it would also make sense to allow removing by value?
const fruits = Immutable(['apple', 'banana', 'cherry']);
fruits.without('banana'); // ['apple', 'cherry']
No, because it leads to ambiguity:
const fruits = Immutable([3, 2, 1]);
fruits.without(1); // ?
Ok then, maybe it's a rabbit hole but it seems like most of the time, you would know the value but not the index. How about something like this?
const fruits = Immutable(['apple', 'banana', 'cherry']);
fruits.without('banana', { byValue: true }); // ['apple', 'cherry']
@Aaronius @markhicken
but like this data:
const fruits = Immutable([{a:['aaa','bbb','ccc']}, 'banana', 'cherry']);
how can i remove 'bbb'.
question 2:
the without fn will not change the index and the array will lost the array fn , so after call without fn ,the array can not call .map ,.flatMap, _.forEach..... ,only can call for(let i in array), just like this :
The
without
method allows a property to be a removed from an object. I propose that it should also allow an item to be removed from an array: