tuplesjuliabigfloat

pushing a big float inside a tuple Julia


I am trying to "push" a big float into a Tuple. But get following error:

# where test() is a function with big floats as values

store = Tuple{Any, Any}][]
for i in 1:10
    push!(store, test(i))
end
store

enter image description here

The error message mentions convert() as a solution, but I am not sure how to convert test().


Solution

  • You cannot push BigFloat into a container that accepts only Tuples. Your container has to accept BigFloats instead, so initialize it with:

    store = BigFloat[]
    

    Also note that you could have just written:

    store = test.(1:10)