An active engineer explains how to use Ruby's delete method [for beginners]
I will explain how to use the delete method of Ruby.
If you're not familiar with Ruby in the first place, you can read the article that explains what Ruby is for a deeper understanding.
This article is based on the contents of the Ruby course of TechAcademy's online boot camp.
What is the delete method?
The delete method deletes the element specified by the argument from the array.The returned value contains the deleted element, and if the specified element does not exist, nil is returned.
A related method is the delete_at method.This is a method to specify the index element and delete it.
I also use this a lot, so let's remember it.
How to delete an element from an array with the delete method
The basic usage is just to pass the element to be deleted as an argument.
fruits = ["apple", "orange", "banana", ...