How do I use the modulus operator?

47 views Asked by At

When using the % operator I am left with the error "Did you forget a , here?". Is there another keyword for % in ReScript?

Js.log(20 % 2) 

Note: This is a translation of this question for ReasonML.

1

There are 1 answers

0
glennsl On

The modulo operator is a plain function called mod in ReScript. It can be used either with or without a pipe:

let x = 20->mod(2)
let y = mod(20, 2)

It's documented in the language overview, comparing JavaScript constructs with their equivalent in ReScript.