How to implement Lionel Zoubritzky's removetype() function?

That is not possible, since all values in Julia have a concrete type and Any is abstract.

But perhaps you want a function removetype(x) which returns x but which Julia’s type inference cannot figure out the return type?

If so, the following should work.

removetype(x) = Base.invokelatest(identity, x)
5 Likes