paulk-asert commented on code in PR #2215:
URL: https://github.com/apache/groovy/pull/2215#discussion_r2083133787


##########
src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java:
##########
@@ -1877,6 +1878,77 @@ public static StringBuilder leftShift(final 
StringBuilder self, final Object val
         return self;
     }
 
+    
//--------------------------------------------------------------------------
+    // make StringBuilder behaves like a stack of chars
+
+    /**
+     * Since StringBuilder is a basic dynamic container of chars, sometimes it 
should
+     * behave like a stack of chars at the same time.
+     * stack's methods should have: push(), peek(), pop(), size(), isEmpty()
+     * <pre class="groovyTestCase">
+     * def st = new StringBuilder()
+     * // stack in cases:
+     * st.push('B')
+     * assert st.toString() == 'B'
+     * st.push('a')
+     * assert st.toString() == 'Ba'
+     * st.push('r')
+     * assert st.toString() == 'Bar'
+     * assert st.size() == 3
+     * assert st.isEmpty() == false
+     * // stack out cases:
+     * assert st.peek() == 'r' as char
+     * assert st.pop() == 'r' as char
+     * assert st.toString() == 'Ba'
+     * assert st.peek() == 'a' as char
+     * assert st.pop() == 'a' as char
+     * assert st.toString() == 'B'
+     * assert st.size() == 1
+     * assert st.isEmpty() == false

Review Comment:
   Off issue, but I'll just make a comment. Groovy 5 supports JDK 11-25. The 
minimal JDK version shouldn't affect those working on JDK 17-24. We just 
haven't made use of any changes requiring above JDK11 as yet. We should be on 
to Groovy 6 soon and JDK17+ will be up for grabs at that point.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to