googlecodelabs / feedback

Provide feedback to our codelabs by filing an issue here
18 stars 22 forks source link

[your-first-webgpu-app] Reserved keyword `in` used in example code #1421

Closed beefchimi closed 2 months ago

beefchimi commented 3 months ago

You give an example of "ping-pong state" for the reader to try (but not to copy into the project). The reader may want to copy/paste this example in order to test it out, only to hit an execution error. This is because one of the arguments is named in, which is a reserved keyword.

My proposal:

function simulate(incoming = [], outgoing = []) {
  outgoing[0] = 0;

  for (let i = 1; i < incoming.length; ++i) {
     outgoing[i] = incoming[i-1];
  }
}

Additionally, there is a very minor issue on the previous page: https://codelabs.developers.google.com/your-first-webgpu-app#5

There appear to be some rogue * characters. If you search for Another alternative, you should find it:

Screenshot ![error-1](https://github.com/user-attachments/assets/86520eef-c92c-4711-a82b-586c220f89f4)
beaufortfrancois commented 3 months ago

Thank you really much @beefchimi!

incoming = [], outgoing = [] would work. I also like inArray, outArray.

Thanks for catching the * characters issue as well!

I'll let you know when the codelab is updated.

beaufortfrancois commented 2 months ago

This issue is now fixed. See https://codelabs.developers.google.com/your-first-webgpu-app?hl=en#5 and https://codelabs.developers.google.com/your-first-webgpu-app?hl=en#6