Last active
February 25, 2023 14:27
-
-
Save ronaldwolvers/01dd0f0076f8a55f7787446a790a3a3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Tested with Go 1.19 | |
| func RemoveElementFromSliceAtIndex[type_param any](s []type_param, index int) []type_param { | |
| return append (s[:index], s[index+1:]...) | |
| } | |
| //Calling the function | |
| RemoveElementFromSliceAtIndex[Your_Type](slice, index_of_item_to_remove) | |
| //This function cannot be called while looping as the item at index_of_item_to_remove+1 will reside at index_of_item_to_remove after calling this function! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment