Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make without support removing item from an array #239

Open
Aaronius opened this issue Nov 30, 2017 · 4 comments
Open

Make without support removing item from an array #239

Aaronius opened this issue Nov 30, 2017 · 4 comments

Comments

@Aaronius
Copy link

Aaronius commented Nov 30, 2017

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:

const fruits = Immutable(['apple', 'banana', 'cherry']);
fruits.without(1); // ['apple', 'cherry']
@markhicken
Copy link

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']

@Aaronius
Copy link
Author

No, because it leads to ambiguity:

const fruits = Immutable([3, 2, 1]);
fruits.without(1); // ?

@markhicken
Copy link

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']

@SunXinFei
Copy link

SunXinFei commented May 17, 2018

@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 :
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants