Replies: 2 comments
-
|
V does not allow this, on purpose. Things can become far too confusing, trying to figure out where a method was declared. If it can only be declared inside the same module, that makes things a lot simpler. You can, however, make an alias to something in another module, and add methods to the alias. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thanks, I known the alias way, it need extra convert between orignal struct and alias type. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If original module struct no a method, but current module has a function, that first argument is other module's struct, and the name is the same as requested one, then this function can seem as the struct's method.
Example: I want
os.Process.name() stringmethod,This can limit only used in current module.
Beta Was this translation helpful? Give feedback.
All reactions