Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange boo language syntax

Tags:

closures

boo

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

setter = { value | a = value }

What does the | operator mean?

like image 648
Artem Tikhomirov Avatar asked Jun 24 '26 22:06

Artem Tikhomirov


2 Answers

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
like image 61
dF. Avatar answered Jun 28 '26 17:06

dF.


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.

like image 40
Adam Wright Avatar answered Jun 28 '26 18:06

Adam Wright



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!