def list = [2, 1, 3]
list.remove(2)
assert list == [1, 3] // throws AssertionError, 'cause list = [2, 1]
Thursday, February 15, 2007
How can I remove value "2"?
In Groovy, you can remove an object from a list by using remove(int index) or remove(object obj). But if I have a list of ints, how can I remove an object by "value" rather than the index?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment