In the julia code below, the first entry of a_b will be updated in a for-loop. However, I want it to always stay an integer regardless of what it gets updated to, because I get the error: "ERROR: LoadError: ArgumentError: invalid index: 7.0 of type Float64" when I do the final line of my code as it is currently written below (the 7.0 is because ultimately the j in which we terminally assign a_b[1] to is indeed 7.0).
How does one accomplish this? Is there a way to preset the types for the entries in an array analogous to how one can set types when you define a dictionary in julia?
a_b = [0, 1.0]
for j in 1 : 7
if T_w[j] > a_w_comma_T_w[2] && T_w[j] < a_b[2]
a_b[1] = j
a_b[2] = T_w[j]
end
end
println("This is a_b: ", a_b)
T_prime = copy(T_w)
T_prime[a_b[1]] = a_w_comma_T_w[2]
I think the problem is that the second entry in the array is a float (which I want to keep), and so it makes the whole array a float. However, I'm still not sure how to fix it.