elliotchance / pie

🍕 Enjoy a slice! A utility library for dealing with slices and maps that focuses on type safety and performance.
https://pkg.go.dev/github.com/elliotchance/pie/v2
MIT License
1.96k stars 91 forks source link

remove element by value and by index #180

Closed ismlsmile closed 8 months ago

ismlsmile commented 2 years ago

Could I remove an element by its value and index ?

elliotchance commented 2 years ago

I'm not sure if you mean you wish to remove an element when its matches an index and it's value, or if you mean you want independent processes to do either.

There is no function for removing by index (although, there should be). If you want to remove by value, you can use Filter or FilterNot.

chocolacula commented 1 year ago

I am ready to implement a function for removing by index. I think issue https://github.com/elliotchance/pie/issues/171 is related to this one. @elliotchance approve or correct me please and I'll do that as soon as I can.

elliotchance commented 1 year ago

Go for it. The linked diff was against pie v1 which I'm not supporting anymore.

chocolacula commented 1 year ago

Added in https://github.com/elliotchance/pie/pull/194

chocolacula commented 8 months ago

@elliotchance perhaps, the issue could be closed because removing by index was implemented, and filtering function already exists.

elliotchance commented 8 months ago

@chocolacula yeah, good point