Skip to content

Commit bfaa0d5

Browse files
committed
GROOVY-11655:Create extension method to make StringBuilder behave like stack(-- remove st.isEmpty() test -- jdk11)
1 parent 69397ad commit bfaa0d5

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,8 +1884,8 @@ public static StringBuilder leftShift(final StringBuilder self, final Object val
18841884
/**
18851885
* Since StringBuilder is a basic dynamic container of chars, sometimes it should
18861886
* behave like a stack of chars at the same time.
1887-
* stack's methods should have: push(), peek(), pop(), size(), isEmpty()
1888-
* here just need to add: push(), peek() and pop()
1887+
* stack's methods should have: push(), peek(), pop(), size(), isEmpty().
1888+
* here just need to add: push(), peek() and pop().
18891889
* <pre class="groovyTestCase">
18901890
* def st = new StringBuilder()
18911891
* // stack in cases:
@@ -1896,7 +1896,6 @@ public static StringBuilder leftShift(final StringBuilder self, final Object val
18961896
* st.push('r')
18971897
* assert st.toString() == 'Bar'
18981898
* assert st.size() == 3
1899-
* assert st.isEmpty() == false
19001899
* // stack out cases:
19011900
* assert st.peek() == 'r' as char
19021901
* assert st.pop() == 'r' as char
@@ -1905,9 +1904,7 @@ public static StringBuilder leftShift(final StringBuilder self, final Object val
19051904
* assert st.pop() == 'a' as char
19061905
* assert st.toString() == 'B'
19071906
* assert st.size() == 1
1908-
* assert st.isEmpty() == false
19091907
* assert st.pop() == 'B' as char
1910-
* assert st.isEmpty() == true
19111908
* </pre>
19121909
*
19131910
* @param self a StringBuilder obj

0 commit comments

Comments
 (0)