To declare a float array in Go, you can use array literal notation or the make() function.
In this example,
floatArray
with predefined values using array literal notation.package main
import "fmt"
func main() {
floatArray := []float64{1.2, 3.4, 5.6}
fmt.Println("Float Array:", floatArray)
}
Float Array: [1.2 3.4 5.6]
In this example,
emptyFloatArray
using the make() function without any elements.package main
import "fmt"
func main() {
emptyFloatArray := make([]float64, 0)
fmt.Println("Empty Float Array:", emptyFloatArray)
}
Empty Float Array: []
In this tutorial, we learned How to Declare a Float Array in Go language with well detailed examples.