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
Class methods can't be included from modules #7927
Comments
This behaviour is copied without modification (as far as I know) from Ruby. I'm not certain it is optimal though - I wouldn't really mind having module behave like Rails concerns (which is one way to handle it). But to actually answer your question, you can create a module like
and then use the EDIT: Fix typo, that @malte-v pointed out |
If you want to use |
This works exactly like in Ruby though I always wondered whether only include should exist in the language (though one use case of extend in the standard library is ENV extends Enumerable, but that could always be something like ENV = Env.new and making Env include Enumerable). It would also simplify the language a bit. |
I'm in favor of removing |
including modules inside classes to now shadow-act as a class method (when it's really a method from a the compiler is doing us a favor by showing this error |
@girng Can you clarify why this would be confusing? Modules can also have class methods and variables. |
One major thing to consider when removing |
@malte-v Not sure, but off the top of my head, if a developer is looking for included methods in a class, they are going to be looking for methods under a class, not a module |
|
I'm going to close this because this is working as expected, at least with the current semantics. Maybe in the future we'll change them but it's independent of this issue being open. |
For some reason class methods can't be included from modules:
Is this the desired behaviour? If so, why isn't this allowed?
The text was updated successfully, but these errors were encountered: