|
Winkle-Daddy posted:My question is, can the Name() function take parameters through an interface? What would be the suggested method for passing arguments be? The only way I could think to do it in this example would be to extend the User struct to include any options I want set, then set them when I dereference into the variable "u" which (should) make it accessible to the function the interface calls. That feels kind of dirty though, would that be considered the "go way" of doing things? I'm not sure what you mean here but you can just pass arguments like a normal function. code:
|
# ¿ Aug 28, 2015 22:24 |
|
|
# ¿ May 4, 2024 12:47 |
|
Winkle-Daddy posted:Hmm, okay, but here: well, "Greet" doesn't really support this, but greet isn't part of the interface. All the interface declaration states is that if "x" is a Namer you will be able to do x.Name() and get a string. If the interface states that x.Name takes some arguments it's up to the caller to pass those arguments.
|
# ¿ Aug 28, 2015 22:44 |