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 213 views
213 views asked Aug 31, 2020 by avibootz
1 answer 183 views
1 answer 221 views
1 answer 234 views
234 views asked Aug 30, 2020 by avibootz
1 answer 193 views
1 answer 226 views
...