rescript-compiler
rescript-compiler copied to clipboard
Early return / break
Investigate implementing early return from functions / breaking from loops.
I recently used this helper in my code:
let forOf: (array<'t>, 't => unit, unit => bool) => unit = %raw(`
function (items, callback, shouldBreak) {
for (let i = 0; i < items.length; i++) {
if (shouldBreak()) {
break;
}
callback(items[i])
}
}
`)
So, I would not mind early return from functions and breaking from loops.