Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Subclasses and pattern matching
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Subclasses and pattern matching

Possibly I'm being dumb here, but wouldn't it be better to use
a union type, eg:

type num = Int of int | Float of float

type list_of_nums = num list

let print_num = function
    Int i -> print_endline (string_of_int i)
  | Float f -> print_endline (string_of_float f)

let print_nums = List.iter print_num


Richard Jones.
Merjis Ltd. - all your business data are belong to you.
C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes,
trees, string funcs, pool allocator:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: