In my code I have:
type Dimension big.Int
However, it is not clear to me how I can initialize a dimension object. I know that I can create a big.Int object by doing:
i := big.NewInt(100)
However, how do I convert it to Dimension
, or better, how can I initialized it directly as Dimension
?
Given:
type Dimension big.Int
There is no way to declare a Dimension
without using the big
package's Int
initializer, since it contains unexported fields. So your best bet is to wrap the underlying initializer with your own:
func NewDimension(i int64) *Dimension {
x := big.NewInt(100)
z := Dimension(*x)
return &z
}
Then call it as:
i := NewDimension(100)