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
s.ReplaceAll("i", "r").Capitalize()
Aim : provide a type of strings (Str) which enables python-like string methods chaining as in:
s : = Str{"Hello Woild"} s.ReplaceAll("i", "r").Capitalize() //-> HELLO WORLD
The motivations are:
Exemple of implementation:
package str import "strings" type Str struct { Str string } func New(s string) Str { return Str{s} } func (s Str) String() string { return s.Str } func (s *Str) Capitalize() *Str { s.Str = strings.ToUpper(s.Str) return s } func (s *Str) ReplaceAll(c1 string, c2 string) *Str { s.Str = strings.Replace(s.Str, c1, c2, -1) return s }
Exemple of use:
// Testing Str: s := Str{"Hello Woild"} fmt.Printf("%s\n", s.ReplaceAll("i", "r").Capitalize()) println(s.ReplaceAll("i", "r").Capitalize().Str)
Alternative implementation (immutable Str strings):
package str import "strings" type Str struct { Str string } func New(s string) Str { return Str{s} } func (s Str) String() string { return s.Str } func (s Str) Capitalize() Str { s.Str = strings.ToUpper(s.Str) return s } func (s Str) ReplaceAll(c1 string, c2 string) Str { s.Str = strings.Replace(s.Str, c1, c2, -1) return s }
The text was updated successfully, but these errors were encountered:
This feature is supported already.
Sorry, something went wrong.
s := "Hello world???" println s.replaceAll("?", "!").toTitle // HELLO WORLD!!!
No branches or pull requests
Proposal
Aim : provide a type of strings (Str) which enables python-like string methods chaining as in:
Background
The motivations are:
Workarounds
Exemple of implementation:
Exemple of use:
Alternative implementation (immutable Str strings):
The text was updated successfully, but these errors were encountered: