golang?
                  
                  
                  var slice1 = []int{0,1,2,3,4,5}
                  
                  
                  cutElement := 2
                  
                  
                  var slice2 []int
                  
                  
                  for i:= 0 ; i < len(slice1); i++{
                  
                  
                  if i == cutElement {
                  
                  
                  continue
                  
                  
                  }
                  
                  
                  slice2 = append(slice2,slice1[i])
                  
                  
                  *&slice1[i] = nil // How can I clear this element of slice in this situation?
                  
                  
                  }
                  
                  
                
1. Iterating over slices like this is not idiomatic, you should use something like for i, element := range slice1 { } 2. Removing an element from a slice can be done in several ways, you can check that out here
Обсуждают сегодня