Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Ruby/ruby-array-deletion-i.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def end_arr_delete(arr)
# delete the element from the end of the array and return the deleted element
arr.pop
end

def start_arr_delete(arr)
# delete the element at the beginning of the array and return the deleted element
arr.shift
end

def delete_at_arr(arr, index)
# delete the element at the position #index
arr.delete_at(index)
end

def delete_all(arr, val)
# delete all the elements of the array where element = val
arr.delete(val)
end