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 299 views
1 answer 266 views
1 answer 289 views
1 answer 318 views
1 answer 310 views
...