How to delete element from array in Ruby

2 Answers

0 votes
arr = ["ruby", "c++", "go", "php", "java"]
 
arr.delete_at(1)
 
print arr



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

 



answered Aug 31, 2020 by avibootz
0 votes
arr = ["ruby", "c++", "go", "php", "java"]
 
arr.delete("go")
 
print arr



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

 



answered Aug 31, 2020 by avibootz

Related questions

1 answer 219 views
1 answer 183 views
1 answer 193 views
1 answer 221 views
1 answer 226 views
1 answer 225 views
...