开发者

How can I prevent "- : unit = ()" from appearing after my output in the ocaml toplevel?

开发者 https://www.devze.com 2023-02-17 15:11 出处:网络
This code for i=0 to 5 do print_string \"a\" done;; will output aaaaaa- : unit = () But how can I output just \"aaaaaa\" without outputting the value of for-e开发者_如何学Goxpression?You are not

This code

for i=0 to 5 do print_string "a" done;;

will output

aaaaaa- : unit = ()

But how can I output just "aaaaaa" without outputting the value of for-e开发者_如何学Goxpression?


You are not really printing the value of the expression; it's just that you are within the session of the interpreter, which by default prints the value/type of the evaluated expression. If you compiled your program it would just print the a's.


You could compile your program; this way you won't get the type information from the interpreter -- which is : unit = ()

0

精彩评论

暂无评论...
验证码 换一张
取 消