Creating and invoking an anonymous function in a single statement

前端 未结 4 1924
旧巷少年郎
旧巷少年郎 2020-12-09 10:03

A php closure or anonymous function is used to create function without specifying its name.

Is it possible to call them without assigning to identifier as we do in J

4条回答
  •  离开以前
    2020-12-09 10:50

    Doesn't look like it, as they still have to be declared with the function() {} notation, and on my 5.3.2 install, trying your sample notion returns an unexpected '(' syntax error. The doc page on closures doesn't mention it either.

    Maybe it'll become possible once they patch up the parser to allow somefunction()[2] array dereferencing.

提交回复
热议问题