Standard library / slices
slices.Max()
Returns the largest ordered element; panics on empty input and propagates floating-point NaN. Expected stdout: '8\n'.
Formal Syntax & Structure
go syntaxgo
func Max[S ~[]E, E cmp.Ordered](x S) EParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | S | Input value or collection to process. |
Return Value
E
Returns the largest ordered element; panics on empty input and propagates floating-point NaN.
Working Example
Example Snippetgo
package main
import ( "fmt" "slices")
func main() { fmt.Println(slices.Max([]int{8, 3, 5}))}