Reputation: 5339
I am trying to read from a file where each line contains some integer
But when I gave like this
f=open("data.txt")
a=readline(f)
arr=int64[]
push!(arr,int(a))
I am getting
ERROR: no method getindex(Function)
in include_from_node1 at loading.jl:120
Upvotes: 3
Views: 4422
Reputation: 42109
The error comes from int64[]
, since int64
is a function and you are trying to index it with []
. To create an array of Int64
(note the case), you should use, e.g., arr = Int64[]
.
Another problem in your code is the int(a)
- since you have an array of Int64
, you should also specify the same type when parsing, e.g., push!(arr,parseint(Int64,a))
Upvotes: 6