A way to get the latest method of a function?

Hi, everyone.

Example:


f(x::Int) = x+1
mt = get_latest_method(f) # mt -> function f with signature Int
f(x::Float64) = x*2.0
mt = get_latest_method(f) # mt -> function f with signature Float64
f(x::Int,y::Float64) = x*y
mt = get_latest_method(f) # mt -> function f with signature (Int,Float64)

Is there a way to do this?

please don’t tell me to diff between 2 methods(f) to see which one it is.
There should be adding order to the methodlist

Thanks

Basically no. Why do you need this? If you want to differenciate between methods you should just use multiple functions.

2 Likes

Yes there is an order to the method list, but it’s based on specificity more than temporal sequence of addition.

Do you know about m = @which f(1, 1.0)?

2 Likes

I see that is enlightening.

Thanks