How to find if a method is implemented for an interface?

One reading of the original question is whether the specific method2 for a subtype of Foo (e.g., Bar) exists, as opposed to a method for Foo or an intermediate abstract type. This may be tested with

:method2 in [m.name for m in methodswith(Bar)]

Other replies seem to accept the more general methods, and probably they fit your needs, but perhaps this expression will help anyone who (mis-)reads the question as I did. The generality applies to method_exists and applicable, but I don’t understand how type hierarchy interacts with traits.

While I am at it, I will express the hope that @ChrisRackauckas will find the time to write a blog post about traits, since (a) he is one of the few package writers using them, (b) he writes good blog posts, and (c) his real-world use cases may guide the developers to optimize the implementation of traits in the language proper.

1 Like