Error occurred when I Push! this to Array{Any}

64 views
Skip to first unread message

cheng wang

unread,
Oct 8, 2015, 6:48:38 AM10/8/15
to julia-users
Hello everyone,

I got this error by the compiler (Julia 0.4rc):
ERROR: LoadError: MethodError: `push!` has no method matching push!(::Array{Any,1}, ::Tuple{Array{ASCIIString,1},Array{ASCIIString,1},TestFilter})

As far as I see, this pushing should be ok. Could someone help ?

Best,
Cheng

Simon Danisch

unread,
Oct 8, 2015, 6:56:30 AM10/8/15
to julia-users
This should work and nowadays overwritting push! should throw an error, so it's unlikely that you did this.
What usually helps is to give a minimal reproducable example, e.g. via a github gist.

Best,
Simon

cheng wang

unread,
Oct 8, 2015, 7:55:01 AM10/8/15
to julia-users
Simon, I defined a new push! methods.
However the error thrown is "MethodError: `push!` has no method..." followed by "you may have intended to import Base.push!"
So I misunderstood the error message.
After I changed the function name, the error is fixed. Thanks very much!

Btw, what is the right way to add new methods for `push!`? Is this discouraged?

Kristoffer Carlsson

unread,
Oct 8, 2015, 7:56:16 AM10/8/15
to julia-users
The right way is to import Base.push! and then add your owns. You probably shouldn't overwrite the ones for Base types but for your own types, it is perfectly acceptable.

cheng wang

unread,
Oct 8, 2015, 8:01:25 AM10/8/15
to julia-users
Thanks!
Reply all
Reply to author
Forward
0 new messages