Groovy - pop()


Advertisements

Removes the last item from this List.

Syntax

Object pop() 

Parameters

None

Return Value

The popped value from the list.

Example

Following is an example of the usage of this method −

class Example { 
   static void main(String[] args) { 
      def lst = [11, 12, 13, 14]; 

      println(lst.pop()); 
      println(lst); 
   } 
}

When we run the above program, we will get the following result −

14 
[11, 12, 13]
groovy_lists.htm
Advertisements