Created
November 27, 2023 11:16
-
-
Save lalizita/6abf4ec8b928ffcf565e9b31cc0ce4da to your computer and use it in GitHub Desktop.
go_array_op
This file contains 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
func main() { | |
var array [3]string | |
array[0] = "Lais" | |
array[1] = "Juliana" | |
array[2] = "Ricardo" | |
//Essa operação não é possível pois o tamanho do array é 3 | |
// array[3] = "Joao" | |
fmt.Printf("%v+\n", array) | |
//Adicionar itens no final do array | |
var melhorAnime [4]string | |
for i := 0; i < 4; i++ { | |
melhorAnime[i] = "naruto" | |
} | |
fmt.Printf("%q\n", melhorAnime) | |
//Exemplo de slice que representa uma fatia | |
//Operação de remoção: | |
animes := []string{"dragonball", "naruto", "jujutsu"} | |
animes = append(animes[:1], animes[1+1:]...) | |
fmt.Printf("%q\n", animes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment