Standard library / cmp
cmp.Less()
Reports whether x precedes y, including NaN before non-NaN floating-point values. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func Less[T Ordered](x, y T) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | T | Input value or collection to process. |
| y | T | Second value to compare. |
Return Value
bool
Reports whether x precedes y, including NaN before non-NaN floating-point values.
Working Example
Example Snippetgo
package main
import ( "cmp" "fmt" "math")
func main() { fmt.Println(cmp.Less(math.NaN(), 1.0), cmp.Less(1.0, math.NaN()))}