groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleitner <...@git.apache.org>
Subject [GitHub] groovy pull request #419: GROOVY-6396: same linkedlist code different behavi...
Date Sun, 18 Sep 2016 04:43:38 GMT
Github user jwagenleitner commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/419#discussion_r79297442
  
    --- Diff: src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java ---
    @@ -8928,6 +8932,27 @@ public int compare(Map.Entry<K, V> e1, Map.Entry<K, V>
e2) {
             if (self.isEmpty()) {
                 throw new NoSuchElementException("Cannot pop() an empty List");
             }
    +        return self.remove(0);
    +    }
    +
    +    /**
    +     * Removes the last item from the List. Using add() and pop()
    +     * is similar to push and pop on a Stack.
    +     * <pre class="groovyTestCase">
    +     * def list = ["a", false, 2]
    +     * assert list.removeLast() == 2
    +     * assert list == ["a", false]
    +     * </pre>
    +     *
    +     * @param self a List
    +     * @return the item removed from the List
    +     * @throws NoSuchElementException if the list is empty and you try to pop() it.
    +     * @since 2.5.0
    +     */
    +    public static <T> T removeLast(List<T> self) {
    +        if (self.isEmpty()) {
    +            throw new NoSuchElementException("Cannot pop() an empty List");
    --- End diff --
    
    `pop()` -> `removeLast()`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message