Trying to delete from this array:
array = ["Dog", "Cat", "John Cena"]
But those won't work:
array.delete(1)
array.delete([1])
Any help is appreciated.
Alternatively:
array = ["Dog", "Cat", "John Cena"]
array[1, 1] = []
array # => ["Dog", "John Cena"]
As stated before you should be using Ruby Docs for help like this Ruby has amazing documentation and is a shame to waste the wealth of knowledge here.
https://ruby-doc.org/core-2.1.0/Array.html#method-i-delete_at
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.