Easy Learning Go: Step by step to lead beginners to learn Go better and fast by Hu Yang

Easy Learning Go: Step by step to lead beginners to learn Go better and fast by Hu Yang

Author:Hu, Yang [Hu, Yang]
Language: eng
Format: epub
Published: 2020-06-03T16:00:00+00:00


var scores = []int {90 , 70 , 50 , 80 , 60 , 85 } // initial a slice

fmt.Println(scores[0 ])

fmt.Println(scores[2 ])

fmt.Println(scores[4 ])

}

Result:

90

50

60

Knowledge Tips

len(): function returns the number of items

2. Print all slice slice.go

package main

import "fmt"

func main() {

var scores = []int {90 , 70 , 50 , 80 , 60 , 85 }

// Print all slice

var length = len (scores)

for i := 0 ; i < length; i++ {

fmt.Println(scores[i])

}

}

Result:

90

70

50

80

60

85



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.