reflect.ArrayOf() Function in Golang with Examples
Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.ArrayOf() Function in Golang is used to get the array type with the given count and element type, i.e., if x represents int, ArrayOf(10, x) represents int. To access this function, one needs to imports the reflect package in the program.
Syntax:func ArrayOf(count int, elem Type) Type
Parameters: This function takes two parameters of int type (count) and Type type(elem).
Return Value: This function returns the array type with the given count and element type.
Below examples illustrate the use of the above method in Golang:
&[1 4 9 16]