From e0d65c98ea2e189e3de71c6fe10d1949d7c0b28b Mon Sep 17 00:00:00 2001 From: Korvin Szanto Date: Tue, 22 Nov 2022 11:52:25 -0800 Subject: [PATCH] Clarify fn keyword and add an example for a short closure being passed as an argument --- spec.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 841bf6b..f5c590a 100644 --- a/spec.md +++ b/spec.md @@ -1188,7 +1188,7 @@ $foo->bar( Short closures, also known as arrow functions, MUST follow the same guidelines and principles as long closures above, with the following additions. -The `fn` keyword MUST be preceded by a space, and MUST NOT be succeeded by a space. +The `fn` keyword MUST NOT be succeeded by a space. The `=>` symbol MUST be preceded and succeeded by a space. @@ -1211,6 +1211,8 @@ $func = fn( int $y, ): int => $x + $y; + +$result = $collection->reduce(fn(int $x, int $y): int => $x + $y, 0); ``` ## 8. Anonymous Classes