Let us motivate the value of augmentations by starting with the following example. Suppose that we would like a function to wrap a string with a left and right string. We could do that in Golo as follows:
function wrap = |left, str, right| -> left + str + right # (...) let str = wrap("(", "foo", ")") println(str) # prints "(abc)"
Defining functions for such tasks makes perfect sense, but what if we could just add the wrap
method to all instances of java.lang.String
instead?