Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Remove element of slice

package main

import (
	"fmt"
)

func main() {
	celestialObjects := []string{"Moon", "Gas", "Asteroid", "Dwarf", "Star", "Commet"}
	fmt.Println(celestialObjects)

	celestialObjects = append(celestialObjects[:3], celestialObjects[4:]...)
	fmt.Println(celestialObjects)

}
[Moon Gas Asteroid Dwarf Star Commet]
[Moon Gas Asteroid Star Commet]