You are viewing a single comment's thread. Return to all comments →
def end_arr_delete(arr) # delete the element from the end of the array and return the deleted element arr.push 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
Seems like cookies are disabled on this browser, please enable them to open this website
Ruby Array - Deletion
You are viewing a single comment's thread. Return to all comments →
def end_arr_delete(arr) # delete the element from the end of the array and return the deleted element arr.push 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