After browsing through Rescript's API, it seems like there is no function that compares 2 strings that returns a boolean. The best option is localeCompare but it behaves somewhat different from the JS's ==. Why does localeCompare return a float instead of an integer?
Comparing String in Rescript
360 Views Asked by heiheihang At
1
You can compare strings using
==in rescript as well. Alternatively there is aString.equalas well if you need a function restricted to strings specifically, The "native" (non-Js) standard library modules such asStringunfortunately seems to be left out of the rescript documentation entirely.localeComapreprobably returns afloatbecause it might be possible for it to return non-integer numbers. JavaScript unfortunately has no integer type, which makes it hard to know if it could returnfloats even if it seems obvious that it shouldn't. I've seen several of this kind of bugs myself in various bindings.