Ruby program to remove the last given number of items from the array

bookmark


arr = [100,101,102,103,104];
item = arr.pop(2);

print "Array: ",arr,"\n";
print "Removed items: ",item,"\n";

 


Output:

Array: [100, 101, 102]
Removed items: [103, 104]