Golang doesn’t allow casting of untyped value, and a literal 4.4
is a float and it knows this, but you haven’t said which kind of float (float64
or float32
)? Type inference works only if you declare a variable which has this value:
x := 4.4
var z int = int(x)
It’s pragmatic and right!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.