Question
I've run into a strange syntax in Boo Language Guide :
setter = { value | a = value }
What does the | operator mean?
Solution
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
OTHER TIPS
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 is correct. The point of the example is to show that lambdas in boo have read and write access to enclosing scope.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow