semicolon (single and double)好吧,我在使用nested if elseOCaml 时遇到了问题。
例如
let union u p q =
let rec unionfy id_ary i =
if i < Array.length id_ary then begin
if id_ary.(i) = p then begin
id_ary.(i) <- id_ary.(q);
print_array id_ary 0;
end
unionfy id_ary (i + 1);
end
else print_string "end of union";
in
unionfy u.id_ary 0;;
编译器说line 18, characters 29-95:
Error: This expression is not a function; it cannot be applied
有问题的行是if id_ary.(i) = p then begin,但我不明白为什么。
另外,谁能告诉我更多关于semicolon事物和的信息nested if else?
以下是我心中的一些问题:
- 我什么时候使用
single semicolon?如果我将它用于多个表达式,我是否必须double semicolon在最后一个表达式之后添加一个? 我可以
begin end在里面使用多个nested if吗?else如果结果是,我似乎不需要添加unit and do nothing?