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

Insert element into array at location

  • insert
numbers = ["One", "Two", "Three"]
puts numbers.insert(1, "Four")
puts numbers

# puts numbers.insert(1, ["1", "2"])
["One", "Four", "Two", "Three"]
["One", "Four", "Two", "Three"]