sml - How to have more than one type in ML? -
is possible in ml allow variable in ml have more 1 type?
for instance, if want node in tree int or string.
node of int * string
i tried results in tuple type of (int, string). don't want tuple, either int or string. allowed?
as pointed out in comment, feature you're looking union types. believe syntax them in sml is:
datatype node = intnode of int | stringnode of string
Comments
Post a Comment