Sum data type: Difference between revisions

Content added Content deleted
m (→‎{{header|Factor}}: more language nitpicking)
(julia example)
Line 135: Line 135:
Type of value must either be Ipv4 or Ipv6.
Type of value must either be Ipv4 or Ipv6.
</pre>
</pre>

=={{header|Julia}}==
Julia allows the creation of union types.
<lang Julia>
julia> MyUnion = Union{Int64, String, Float64, IPv4, IPv6}
Union{Float64, Int64, IPv4, IPv6, String}

julia> arr = MyUnion[2, 4.8, ip"192.168.0.0", ip"::c01e:fc9a", "Hello"]
5-element Array{Union{Float64, Int64, IPv4, IPv6, String},1}:
2
4.8
ip"192.168.0.0"
ip"::c01e:fc9a"
"Hello"

</lang>



=={{header|OCaml}}==
=={{header|OCaml}}==