Logo

Programming-Idioms

History of Idiom 135 > diff from v7 to v8

Edit summary for version 8 by BBaz:
New Pascal implementation by user [BBaz]

Version 7

2016-08-13, 21:25:56

Version 8

2016-08-23, 13:20:33

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
uses classes;
Code
i := items.IndexOf(c);
if i <> -1 then
  items.delete(i);
Comments bubble
items is a container such as TFPList, TList, TObjectList,...