Created
November 7, 2011 16:39
-
-
Save erdi/1345462 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
String value | |
} | |
def list = [new A(value: 'a'), new A(value: 'b'), new A(value: 'c'), new A(value: 'd')] | |
//we don't know the order and what is in list, we want to move object with value 'c' to the beggining of the list | |
def moved = list.find { it.value == 'c' } | |
list.remove(moved) | |
list.putAt(0, moved) | |
assert list.indexOf(moved) == 0 | |
assert list.count(moved) == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment