3

I've run into a strange syntax in Boo Language Guide :

setter = { value | a = value }

What does the | operator mean?

Matt Hamilton
  • 200,371
  • 61
  • 386
  • 320
Artem Tikhomirov
  • 21,497
  • 10
  • 48
  • 68

4 Answers4

5

The documentation of Boo seems to be lacking in this area -- it seems that

setter = { value | a = value }

is shorthand for

setter = def(value):
    a = value
dF.
  • 74,139
  • 30
  • 130
  • 136
4

Well, having never used Boo, my (educated) guess is that it's for passing parameter to the closure lambda-style functions. In this case, { p | C } refers to an anonymous function taking a single parameter bound to p within the code C.

Adam Wright
  • 48,938
  • 12
  • 131
  • 152
2

Adam is correct. The point of the example is to show that lambdas in boo have read and write access to enclosing scope.

Frep D-Oronge
  • 2,618
  • 3
  • 27
  • 27
0

That syntax for specifying code blocks (anonymous functions) has been borrowed from Ruby and Smalltalk

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275