Skip to content

No support for closures in lambdas ? #173

@feedthejim

Description

@feedthejim

Hi,

I'm trying to understand AssemblyScript by doing a little project. Is there no closure on lambdas ?

` trace(rayOrigin: Vector3, rayDirection: Vector3, depth: f64): Vector3 {
let tnear: f64 = Infinity;
let sphere: Sphere | null = null;

this.elements.forEach(
  (sphere: Sphere): void => {
    let hitInfo: Intersection | null = sphere.intersect(
      rayOrigin,
      rayDirection,
    );

`
This bit of code doesn't compile, it throws this error.

`ERROR TS2304: Cannot find name 'rayOrigin'.

       rayOrigin,
       ~~~~~~~~~

in assembly/RayTracer.ts(16,1`

Do i need to pass them as parameters to the lambda ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions