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 216 views
216 views asked Aug 31, 2020 by avibootz
1 answer 187 views
1 answer 235 views
1 answer 239 views
239 views asked Aug 30, 2020 by avibootz
1 answer 201 views
1 answer 236 views
...