dwickern / scala-nameof

Get the name of an variable, function, class member, or type as a string--at compile-time!
MIT License
131 stars 23 forks source link

how to use nameOf for overloaded methods #9

Closed alain-espina closed 4 years ago

alain-espina commented 4 years ago

how do you use nameOf if there are two methods having the same name but different parameters?

dwickern commented 4 years ago

You could use a type annotation like this:

def foo(x: Int) = ???
def foo(x: String) = ???

println(nameOf(foo(_: Int))) // "foo"