Logo

Programming-Idioms

History of Idiom 135 > diff from v26 to v27

Edit summary for version 27 by matthewmcgibbon:
New Java implementation by user [matthewmcgibbon]

Version 26

2019-09-27, 14:35:57

Version 27

2019-09-27, 15:41:17

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Imports
Java.utils.List
Code
items.stream().findFirst().filter(e -> e == "User").ifPresent(e -> items.remove(e));