Chapter 2 - Conditionals and Loops
Exercise 1: Calling Methods
strings package has a
Builder type that is used to build a long text string out of multiple shorter strings. A
strings.Builder value has a variety of different methods you can call, but this exercise is going to focus on these three:
WriteRunemethod accepts a rune as an argument and adds that rune onto the end of the string being built.
WriteStringmethod works just like
WriteRune, except that it accepts a string as an argument.
Stringmethod takes no arguments. Its return value is the accumulated string.
Complete the code sample below. The sample contains
YOUR CODE HERE comments in the places you should add code, with a description of what your code should do.
When you’re ready, have a look at the solution.