Skip to content
New issue

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

sourcecode.Text applied to infix operator works unintuitively. #72

Open
pocorall opened this issue May 13, 2019 · 0 comments
Open

sourcecode.Text applied to infix operator works unintuitively. #72

pocorall opened this issue May 13, 2019 · 0 comments

Comments

@pocorall
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant