You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the compiler doesn't seem to understand how to set type of i, it gives the following error: : cannot use i (type int) as type int64 in assignment.
I know one can do: x[i] = int64(i) or even better, for i := int64(0); i < 1000000; i++ (the later being a bit better for performance) but in this case I would prefer the Go compiler to optimize this out and not have me manually make the changes needed.
Thank you.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
Better type inference in for loops
language: better type inference in for loops
Feb 14, 2016
In the absence of clear, simple rules, I am going to close this.
We like type inference but it needs to be clear and straightforward. This approach requires significant analysis, and it's not always clear whether a solution is possible. This sounds more like Haskell than Go.
Hi,
In the following code:
the compiler doesn't seem to understand how to set type of
i
, it gives the following error:: cannot use i (type int) as type int64 in assignment
.I know one can do:
x[i] = int64(i)
or even better,for i := int64(0); i < 1000000; i++
(the later being a bit better for performance) but in this case I would prefer the Go compiler to optimize this out and not have me manually make the changes needed.Thank you.
The text was updated successfully, but these errors were encountered: