rescript-lang.org icon indicating copy to clipboard operation
rescript-lang.org copied to clipboard

Document ignore function

Open jamessouth opened this issue 4 years ago • 0 comments

Hello!

The VSCode plugin/OCaml library doc for ignore:

'a => unit
Discard the value of its argument and return [()]. For instance, [ignore(f x)] discards the result of
the side-effecting function [f]. It is equivalent to [f x; ()], except that the latter may generate a
compiler warning; writing [ignore(f x)] instead avoids the warning.

This use does not seem to be documented for ReScript or in the search results/syntax lookup. I added a setTimeout to my project and got a compiler error (This has type: Js.Global.timeoutId (defined as Js_global.timeoutId) Somewhere wanted: unit) that I cleared by piping to ignore.

Js.Global.setTimeout(() => myFunc, 1000)->ignore

Thank you!

jamessouth avatar Sep 25 '21 19:09 jamessouth