I'm trying to eval() an expression in a try block as below. However the 
evaluation does not seem to happen and *a* is unchanged  after the code 
block.

a=[]
for i=1:4
    try
        if i==3 error() end
        eval(:(push!(a,i)))
        catch e
    end
end

a evaluates to: 0-element Array{Any,1}


I'm expecting the same result as the code below which does not use eval().
a=[]
for i=1:4
    try
        if i==3 error() end
        push!(a,i)
        catch e
    end
end

a evaluates to:
3-element Array{Any,1}:
 1
 2
 4

Is there a way to use eval() in this situation?

Reply via email to