14

There are code snippets in this Spock wiki page that involve double right arrow operators (>>). For example:

setup:
subscriber.isAlive() >> true

So, what does the >> operator mean in this case? Thank you very much.

JBT
  • 8,498
  • 18
  • 65
  • 104

1 Answers1

19

The right-shift (>>) operator defines the return value or behavior of a stubbed method. You can find more information under Stubbing in the reference documentation.

Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • I'm guessing they used the operator overloading feature of groovy to do this https://stackoverflow.com/questions/6485861/is-it-possible-to-define-a-new-operator-in-groovy – Ben Creasy Feb 17 '23 at 22:36