Hi,
I’ve got this function
let isQuestion = iSay => {
let lastPos = String.length(iSay) - 1;
switch(String.rindex(iSay, '?'), lastPos) {
| (q, l) when q === l => true
| exception Not_found => false
| _ => false
}
}
but if I write it like this:
let isQuestion = iSay => {
let questionPos = String.rindex(iSay, '?');
let lastPos = String.length(iSay) - 1;
switch(questionPos, lastPos) {
| (q, l) when q === l => true
| exception Not_found => false
| _ => false
}
}
it gives a run time error because let questionPos = String.rindex(iSay, '?');
raises an exception before we get catch it in the switch
case. Is there anyway to “delay” this exception from being raised or some other way to handle it in the switch
case?