Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is Zephir supported use keyword in closure? #1318

Closed
jockchou opened this issue Sep 5, 2016 · 2 comments
Closed

Is Zephir supported use keyword in closure? #1318

jockchou opened this issue Sep 5, 2016 · 2 comments

Comments

@jockchou
Copy link

jockchou commented Sep 5, 2016

the code here:https://docs.zephir-lang.com/en/latest/closures.html

namespace MyLibrary;

class Functional
{

    public function map(array! data)
    {
        return function(number) {
            return number * number;
        };
    }
}

How to do If I want use the data value in the closure like this:

namespace MyLibrary;

class Functional
{

    public function map(array! data)
    {
        return function(number) {
            return number * number + data[0];
        };
    }
}

is Zephir support use like php ?

namespace MyLibrary;

class Functional
{

    public function map(array! data)
    {
        return function(number) use (data) {
            return number * number + data[0];
        };
    }
}
@RogerWaters
Copy link

+1

@sergeyklay
Copy link
Contributor

Refs: #888

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants