lundi 4 décembre 2017

Understanding closure and anonymous methods

I trying to understand how closure works under the hood in laravel, but I got to this point and makes not much sense to me.

\Illuminate\Container\Container::wrap

 public function wrap(Closure $callback, array $parameters = [])
 {
    return function () use ($callback, $parameters) {
        return $this->call($callback, $parameters);
    };
 }

Why is this closure wrap inside an anonymous function? Would it be the same as just writing return $this->call($callback, $parameters);?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire