0

I met with the below statements in a scala code

val stage = stage1 ?~> stage2 ?~> stage3 ~> stage4

Can anyone please explain the meaning of the ?~> and how these statements will be evaluated.

3
  • 2
    Where did you see this code? Akka by any chance? I am not sure this is in the standard library Commented Jun 6, 2022 at 5:38
  • Codebase usage scala version 2.12.15 Commented Jun 6, 2022 at 10:34
  • What other libraries are you importing into the code? Commented Jun 6, 2022 at 17:37

1 Answer 1

3

An infix operation a op b is compiler shorthand for a.op(b). So that code is directly equivalent to

((stage1.?~>(stage2)).?~>(stage3)).~>(stage4)

which is evaluated like this:

val t1 = stage1.?~>(stage2)
val t2 = t1.?~>(stage3)
val result = t2.~>(stage4)

?~> is a method of the object stage1 that returns an object that has a ?~> method that returns an object with a ~> method.

What it actually does depends on what library you are using and the type of the stage objects.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.