Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Delete element from array by location

  • delete_at
planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
puts planets.delete_at(1)
puts planets

puts planets.delete_at(1, 3)
puts planets
Venus
["Mercury", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
["Earth", "Mars", "Jupiter"]
["Mercury", "Saturn", "Uranus", "Neptune"]