Sum data type: Difference between revisions

Scala contribution added.
(Updated C header tags)
(Scala contribution added.)
Line 319:
let loopback = IpAddr::V6(String::from("::1"));</lang>
 
=={{header|Scala}}==
{{Out}}See it yourself by running in your browser either by [https://scalafiddle.io/sf/encsuyJ/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/3U8mEeYqTliyKn6ikYnFAg Scastie (remote JVM)].
{{libheader|ScalaFiddle qualified}}
{{libheader|Scastie qualified}}
{{works with|Scala|2.13}}
<lang Scala>case class Envelop[T](member: T)
 
val list = List(
Envelop("a string"),
Envelop(732), // an integer
Envelop('☺'), // a character
Envelop(true) // a boolean value
)
 
list.foreach { case Envelop(element) => println(element) }</lang>
=={{header|zkl}}==
zkl is untyped - it is up to the container to decide if it wants to deal with a type or not.
Anonymous user