We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
__str__
String()
Describe the bug Python classes have an __str__ method that defines how they are printed. Go structs have a String() method that does the same.
Python code example
print("Hello, World!") class A: a = "huh?" def __init__(self, val): self.a = val def __str__(self): return self.a val = A("ok") print(val)
Current behavior (relevant code):
func (self *A) __str__() { return self.a }
Expected behavior
func (self *A) String() { return self.a }
The text was updated successfully, but these errors were encountered:
Cool idea! I'll get on it.
EDIT:
For the test case, let's say we want this:
class A: a: str def __init__(self, val): self.a = val def __str__(self): return self.a def main(): val = A("ok") print(val) if __name__ == '__main__': main()
To go to this:
package main import "fmt" type A struct { a string } func NewA(val string) (self *A) { self = new(A) self.a = val return } func (self *A) String() string { return self.a } func main() { val := NewA("ok") fmt.Println(val) }
Sorry, something went wrong.
a4eec6d
Added! Thanks so much for your suggestion, please share if you have any more!
Thanks for responding so fast! Amazing project!
No branches or pull requests
Describe the bug
Python classes have an
__str__
method that defines how they are printed. Go structs have aString()
method that does the same.Python code example
Current behavior
(relevant code):
Expected behavior
The text was updated successfully, but these errors were encountered: