<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://coderwiki.org/index.php?action=history&amp;feed=atom&amp;title=Enum</id>
	<title>Enum - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://coderwiki.org/index.php?action=history&amp;feed=atom&amp;title=Enum"/>
	<link rel="alternate" type="text/html" href="http://coderwiki.org/index.php?title=Enum&amp;action=history"/>
	<updated>2026-05-19T01:41:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://coderwiki.org/index.php?title=Enum&amp;diff=107&amp;oldid=prev</id>
		<title>Dylan: new: info, example, other sum, other algebraic</title>
		<link rel="alternate" type="text/html" href="http://coderwiki.org/index.php?title=Enum&amp;diff=107&amp;oldid=prev"/>
		<updated>2025-08-15T09:04:13Z</updated>

		<summary type="html">&lt;p&gt;new: info, example, other sum, other algebraic&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;An &amp;#039;&amp;#039;&amp;#039;enum&amp;#039;&amp;#039;&amp;#039; is a [[sum type]] (a type of [[algebraic data type]]) in which its [[value]] represents one of a set number of possible states.&lt;br /&gt;
&lt;br /&gt;
This makes [[Invalid state|invalid states]] unrepresentable, as the [[variable]] of the enum [[data type]] can &amp;#039;&amp;#039;&amp;#039;only&amp;#039;&amp;#039;&amp;#039; store certain [[Value|values]], nothing else.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Say you are writing a program to track animals in a zoo.&lt;br /&gt;
&lt;br /&gt;
You could have an &amp;#039;&amp;#039;&amp;#039;enum&amp;#039;&amp;#039;&amp;#039; type called &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; to store the different animals in the zoo. [[Variable|Variables]] of this [[Data type|type]] could then only contain one of four [[Value|values]]:&lt;br /&gt;
&lt;br /&gt;
* Parrot&lt;br /&gt;
* Monkey&lt;br /&gt;
* Tiger&lt;br /&gt;
* Giraffe&lt;br /&gt;
&lt;br /&gt;
This has the benefit of making [[invalid state]] impossible: we are guaranteed that the value of an &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; [[variable]] will always be one of the 4 above.&lt;br /&gt;
&lt;br /&gt;
== Other sum types ==&lt;br /&gt;
See: [[Sum type]]&lt;br /&gt;
&lt;br /&gt;
== Other algebraic data types ==&lt;br /&gt;
See: [[Algebraic data type]]&lt;/div&gt;</summary>
		<author><name>Dylan</name></author>
	</entry>
</feed>