Standard library / sort

sort.IntSlice.Len()

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

Formal Syntax & Structure

go syntaxgo
func (x IntSlice) 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.IntSlice([]int{3, 1, 2})  fmt.Println(a.Len())}
Go Reference