How to delete the last element from array in Ruby

1 Answer

0 votes
arr = ["ruby", "c++", "go", "php", "java"]
  
print arr, "\n"  
  
arr.pop()
print arr, "\n"

arr.pop()
print arr

 
 
 
# run:
  
# ["ruby", "c++", "go", "php", "java"]
# ["ruby", "c++", "go", "php"]
# ["ruby", "c++", "go"]

 



answered Aug 31, 2020 by avibootz

Related questions

2 answers 326 views
326 views asked Aug 31, 2020 by avibootz
1 answer 266 views
1 answer 317 views
1 answer 309 views
309 views asked Aug 30, 2020 by avibootz
1 answer 288 views
...