Reputation: 3
I am working master's course. I have a program file that run in version julia-0.3.6. And I upgraded the Julia program to version 0.5.0 in linux however the file do not run.
f=open("../info.dat","r")
order,nt,nx,ny,nshot,srcy=int(split(readline(f)[1:6])
ERROR: LoadError: UndefVarError: int not defined
what is the problem?
Upvotes: 0
Views: 450
Reputation: 12051
The int
function has been deprecated in Julia v0.4 and was removed in Julia v0.5, so an UndefVarError
occurs when you try to use it. (Note that functions are first-class objects in Julia, and so are bound to names just like any other variables are. When an unbound name is used, an UndefVarError
is thrown.) The correct way to write your code in Julia v0.5 is
f = open("../info.dat", "r")
order,nt,nx,ny,nshot,srcy = [parse(Int, x) for x in split(readline(f))]
However, this code is not great, because it does not close f
afterward. I would recommend
order, nt, nx, ny, nshot, srcy = open("../info.dat") do f
[parse(Int, x) for x in split(readline(f))]
end
Upvotes: 6