Browse thread
Void type?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Erik de Castro Lopo <mle+ocaml@m...> |
| Subject: | Re: [Caml-list] Void type? |
Stefan Monnier wrote:
>
> Is there a void type in OCaml (i.e. a type which has no values), or a way to
> simulate it?
Yes, the unit type which is written "()".
Objective Caml version 3.09.2
# let x = () ;;
val x : unit = ()
Unit can also be returned from a function, and a function
can have its input of type unit:
# let f () = 3.141 ;;
val f : unit -> float = <fun>
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Unix and C are the ultimate computer viruses." -- Richard P Gabriel