Standard library / sort

sort.StringSlice.Len()

Returns the number of elements in the receiver. Expected stdout: '3\n'.

Formal Syntax & Structure

go syntaxgo
func (x StringSlice) Len() int

Return Value

int

Returns the number of elements in the receiver.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sort")
func main() {  a := sort.StringSlice([]string{"c", "a", "b"})  fmt.Println(a.Len())}
Go Reference