class Array {
public static int MAX_SIZE = 42;
}
Array arr = new Array();
int size = Array.MAX_SIZE;
So, we can create an object of class Array
, and we also have a property of class Array
. What will be the equivalence of this code in Go?
class Array {
public static int MAX_SIZE = 42;
}
Array arr = new Array();
int size = Array.MAX_SIZE;
So, we can create an object of class Array
, and we also have a property of class Array
. What will be the equivalence of this code in Go?
Go has no classes. Go has no static variables. So there is no equivalent.
The closest concepts Go has are package constants, and struct fields. Neither is exactly the same as what you're looking for.