Why this code doesn’t work ? I have the error : maxL not defined
"
maxL=0
for j in 1:size(jobs_in_file,1)
if ((ordered_jobs[j].start_time + ordered_jobs[j].proc) > ordered_jobs[j].due)
maxl1 = maxL + 0
maxL = max(ordered_jobs[j].start_time + ordered_jobs[j].proc - ordered_jobs[j].due, maxL)
end
end
"
Thanks for the help!
for
introduces a new local scope, see https://docs.julialang.org/en/v1/manual/variables-and-scoping/. See https://stackoverflow.com/questions/51930537/scope-of-variables-in-julia for some more discussion and solutions.
2 Likes
You could wrap the code in a let…end block. This would put maxL
in scope.
let
[your code here]
end
2 Likes