We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Ruby Array - Deletion
Ruby Array - Deletion
Sort by
recency
|
121 Discussions
|
Please Login in order to post a comment
Code comments are misleading as it is not clear in all cases if the returned value must be the updated array or the deleted value. I took some minutes to guess that this was the issue. It should be fixed
Please ensure that you adhere to the instructions displayed on the screen and select the suitable option accordingly. alight motion apk ios
def end_arr_delete(arr) deleted_element = arr.pop deleted_element end
def start_arr_delete(arr) deleted_element = arr.shift deleted_element end
def delete_at_arr(arr, index) deleted_element = arr.delete_at(index) deleted_element end
def delete_all(arr, val) arr.delete(val) end
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