-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"this" on static extension methods #348
Comments
This is not a solution (I prefer "this" on class/static methods), but a possible workaround (I don't known if cause a poor performance): Please note the use of
|
See "Smart" static methods with |
Great example and another use case: generic factory with static method (on superclass or interface). In the past, I also needed this... |
Already known that static method in Java don't have a "this" context. But this is not true with other OO languages ("this" on class method referenced the called Class).
I like a static logging method
warn()
declared onObject
, for use on any classIf "static extension methods" allows an optional (for retrocompatibility) first parameter with the called class, as this one:
Now, I can write logs, on any class, calling to static method:
warn("message")
note: this solution centralize logging framework dependency on single class (I don't like imports of logging framework on all classes)
The text was updated successfully, but these errors were encountered: