KScript documentação
PT

Idioma

Traduzido automaticamente do inglês, que é a versão original.

Códigos de erro

KS2006

Uma fn é impressa em vez de chamada. Imprimir uma fn, ou preenchê-la em um texto, mostra o próprio código, porque nada a chama. Isso acontece principalmente com um pipe: o corpo de uma fn vai até o fim da linha, então |> call(...) depois dela passa a fazer parte do corpo. Coloque a fn entre colchetes para que a chamada seja feita sobre ela. A correção rápida faz isso.

<echo value="fn(width, height) => $width * $height |> call(6, 7)" /> <!-- warning: prints the fn's code -->
<echo value="(fn(width, height) => $width * $height)->call(6, 7)" /> <!-- right: 42 -->
<echo value="(fn(width, height) => $width * $height) |> call(6, 7)" /> <!-- right: 42, the brackets end the fn -->
echo fn(width, height) => $width * $height |> call(6, 7)      // warning: prints the fn's code
echo (fn(width, height) => $width * $height)->call(6, 7)      // right: 42
echo (fn(width, height) => $width * $height) |> call(6, 7)    // right: 42, the brackets end the fn

Edit this page on GitHub