Skip to content

Feature Request: Make Append operation return *StringBuilder to facilitate chaining #1

Closed
@varunu28

Description

@varunu28

Typical functionality of a builder function consists of chaining operation. The exisitng implementation of Append function can be modified to return *StringBuilder. This will facilitate chaining operation and end up resulting in cleaner code.

For example current sample code is as below:

sb := Text.StringBuilder{}
sb.Append("Hello")
sb.Append(" ")
sb.Append("World")
fmt.Println(sb.ToString())

With the updated feature, above code will look like:

sb := Text.StringBuilder{}
s := sb.Append("Hello").Append(" ").Append("World").ToString()
fmt.Println(s)

I will be happy to add a POC implementation for this feature and can extend the implementation to other Append functions in future.

Let me know what you think @linkdotnet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions