Open
Description
class MyBuilder {
val builder = new StringBuilder
def add[T](txt: sourcecode.Text[T]): MyBuilder = {
builder append txt.source
this
}
def +[T](txt: sourcecode.Text[T]): MyBuilder = {
builder append txt.source
this
}
}
val hello = 3
val world = "hi!"
new MyBuilder().add(hello).add(world).builder.toString() // equals to "helloworld"
(new MyBuilder() + hello + world).builder.toString() // equals to "hello + worldworld"
I hope that .add(hello).add(world)
and + hello + world
make the same result.
Metadata
Metadata
Assignees
Labels
No labels