CINXE.COM
Enumerated type - Wikipedia
<!DOCTYPE html> <html class="client-nojs skin-theme-clientpref-day mf-expand-sections-clientpref-0 mf-font-size-clientpref-small mw-mf-amc-clientpref-0" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Enumerated type - Wikipedia</title> <script>(function(){var className="client-js skin-theme-clientpref-day mf-expand-sections-clientpref-0 mf-font-size-clientpref-small mw-mf-amc-clientpref-0";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"ecf2d677-8ef7-44b4-a67a-24ad8e8f718e","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Enumerated_type","wgTitle":"Enumerated type","wgCurRevisionId":1258670035,"wgRevisionId":1258670035,"wgArticleId":4723370, "wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Enumerated_type","wgRelevantArticleId":4723370,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFMode":"stable","wgMFAmc":false,"wgMFAmcOutreachActive":false,"wgMFAmcOutreachUserEligible":false,"wgMFLazyLoadImages":true,"wgMFEditNoticesFeatureConflict":false,"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgMFIsSupportedEditRequest":true,"wgMFScriptPath":"", "wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":40000,"wgRelatedArticlesCompat":[],"wgCentralAuthMobileDomain":true,"wgEditSubmitButtonLabelPublish":true,"wgSectionTranslationMissingLanguages":[{"lang":"ace","autonym":"Acèh","dir":"ltr"},{"lang":"ady","autonym":"адыгабзэ","dir":"ltr"},{"lang":"alt","autonym":"алтай тил","dir":"ltr"},{"lang":"am","autonym":"አማርኛ","dir":"ltr"},{"lang":"ami","autonym":"Pangcah","dir":"ltr"},{"lang":"an","autonym":"aragonés","dir":"ltr"},{"lang":"ang","autonym":"Ænglisc","dir":"ltr"},{"lang":"ann","autonym":"Obolo","dir":"ltr"},{"lang":"anp","autonym":"अंगिका","dir":"ltr"},{"lang":"ar","autonym":"العربية","dir":"rtl"},{"lang":"ary","autonym":"الدارجة","dir":"rtl"},{"lang":"arz","autonym":"مصرى","dir":"rtl"},{"lang":"as","autonym":"অসমীয়া","dir":"ltr"},{"lang":"ast","autonym":"asturianu","dir":"ltr"},{"lang":"av","autonym":"авар","dir":"ltr"},{"lang":"avk","autonym": "Kotava","dir":"ltr"},{"lang":"awa","autonym":"अवधी","dir":"ltr"},{"lang":"ay","autonym":"Aymar aru","dir":"ltr"},{"lang":"az","autonym":"azərbaycanca","dir":"ltr"},{"lang":"azb","autonym":"تۆرکجه","dir":"rtl"},{"lang":"ba","autonym":"башҡортса","dir":"ltr"},{"lang":"ban","autonym":"Basa Bali","dir":"ltr"},{"lang":"bar","autonym":"Boarisch","dir":"ltr"},{"lang":"bbc","autonym":"Batak Toba","dir":"ltr"},{"lang":"bcl","autonym":"Bikol Central","dir":"ltr"},{"lang":"bdr","autonym":"Bajau Sama","dir":"ltr"},{"lang":"be","autonym":"беларуская","dir":"ltr"},{"lang":"bew","autonym":"Betawi","dir":"ltr"},{"lang":"bg","autonym":"български","dir":"ltr"},{"lang":"bho","autonym":"भोजपुरी","dir":"ltr"},{"lang":"bi","autonym":"Bislama","dir":"ltr"},{"lang":"bjn","autonym":"Banjar","dir":"ltr"},{"lang":"blk","autonym":"ပအိုဝ်ႏဘာႏသာႏ","dir":"ltr"},{"lang":"bm","autonym":"bamanankan","dir":"ltr"},{"lang":"bn","autonym": "বাংলা","dir":"ltr"},{"lang":"bo","autonym":"བོད་ཡིག","dir":"ltr"},{"lang":"bpy","autonym":"বিষ্ণুপ্রিয়া মণিপুরী","dir":"ltr"},{"lang":"br","autonym":"brezhoneg","dir":"ltr"},{"lang":"bs","autonym":"bosanski","dir":"ltr"},{"lang":"btm","autonym":"Batak Mandailing","dir":"ltr"},{"lang":"bug","autonym":"Basa Ugi","dir":"ltr"},{"lang":"ca","autonym":"català","dir":"ltr"},{"lang":"cdo","autonym":"閩東語 / Mìng-dĕ̤ng-ngṳ̄","dir":"ltr"},{"lang":"ce","autonym":"нохчийн","dir":"ltr"},{"lang":"ceb","autonym":"Cebuano","dir":"ltr"},{"lang":"ch","autonym":"Chamoru","dir":"ltr"},{"lang":"chr","autonym":"ᏣᎳᎩ","dir":"ltr"},{"lang":"ckb","autonym":"کوردی","dir":"rtl"},{"lang":"co","autonym":"corsu","dir":"ltr"},{"lang":"cr","autonym":"Nēhiyawēwin / ᓀᐦᐃᔭᐍᐏᐣ","dir":"ltr"},{"lang":"crh","autonym":"qırımtatarca","dir":"ltr"},{"lang":"cu","autonym": "словѣньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ","dir":"ltr"},{"lang":"cy","autonym":"Cymraeg","dir":"ltr"},{"lang":"da","autonym":"dansk","dir":"ltr"},{"lang":"dag","autonym":"dagbanli","dir":"ltr"},{"lang":"dga","autonym":"Dagaare","dir":"ltr"},{"lang":"din","autonym":"Thuɔŋjäŋ","dir":"ltr"},{"lang":"diq","autonym":"Zazaki","dir":"ltr"},{"lang":"dsb","autonym":"dolnoserbski","dir":"ltr"},{"lang":"dtp","autonym":"Kadazandusun","dir":"ltr"},{"lang":"dv","autonym":"ދިވެހިބަސް","dir":"rtl"},{"lang":"dz","autonym":"ཇོང་ཁ","dir":"ltr"},{"lang":"ee","autonym":"eʋegbe","dir":"ltr"},{"lang":"el","autonym":"Ελληνικά","dir":"ltr"},{"lang":"eml","autonym":"emiliàn e rumagnòl","dir":"ltr"},{"lang":"eo","autonym":"Esperanto","dir":"ltr"},{"lang":"es","autonym":"español","dir":"ltr"},{"lang":"et","autonym":"eesti","dir":"ltr"},{"lang":"eu","autonym":"euskara","dir":"ltr"},{"lang":"fa","autonym":"فارسی","dir":"rtl"},{"lang":"fat","autonym":"mfantse", "dir":"ltr"},{"lang":"ff","autonym":"Fulfulde","dir":"ltr"},{"lang":"fi","autonym":"suomi","dir":"ltr"},{"lang":"fj","autonym":"Na Vosa Vakaviti","dir":"ltr"},{"lang":"fo","autonym":"føroyskt","dir":"ltr"},{"lang":"fon","autonym":"fɔ̀ngbè","dir":"ltr"},{"lang":"frp","autonym":"arpetan","dir":"ltr"},{"lang":"frr","autonym":"Nordfriisk","dir":"ltr"},{"lang":"fur","autonym":"furlan","dir":"ltr"},{"lang":"fy","autonym":"Frysk","dir":"ltr"},{"lang":"gag","autonym":"Gagauz","dir":"ltr"},{"lang":"gan","autonym":"贛語","dir":"ltr"},{"lang":"gcr","autonym":"kriyòl gwiyannen","dir":"ltr"},{"lang":"gl","autonym":"galego","dir":"ltr"},{"lang":"glk","autonym":"گیلکی","dir":"rtl"},{"lang":"gn","autonym":"Avañe'ẽ","dir":"ltr"},{"lang":"gom","autonym":"गोंयची कोंकणी / Gõychi Konknni","dir":"ltr"},{"lang":"gor","autonym":"Bahasa Hulontalo","dir":"ltr"},{"lang":"gpe","autonym":"Ghanaian Pidgin","dir":"ltr"},{"lang":"gu","autonym":"ગુજરાતી","dir": "ltr"},{"lang":"guc","autonym":"wayuunaiki","dir":"ltr"},{"lang":"gur","autonym":"farefare","dir":"ltr"},{"lang":"guw","autonym":"gungbe","dir":"ltr"},{"lang":"gv","autonym":"Gaelg","dir":"ltr"},{"lang":"ha","autonym":"Hausa","dir":"ltr"},{"lang":"hak","autonym":"客家語 / Hak-kâ-ngî","dir":"ltr"},{"lang":"haw","autonym":"Hawaiʻi","dir":"ltr"},{"lang":"he","autonym":"עברית","dir":"rtl"},{"lang":"hi","autonym":"हिन्दी","dir":"ltr"},{"lang":"hif","autonym":"Fiji Hindi","dir":"ltr"},{"lang":"hr","autonym":"hrvatski","dir":"ltr"},{"lang":"hsb","autonym":"hornjoserbsce","dir":"ltr"},{"lang":"ht","autonym":"Kreyòl ayisyen","dir":"ltr"},{"lang":"hu","autonym":"magyar","dir":"ltr"},{"lang":"hy","autonym":"հայերեն","dir":"ltr"},{"lang":"hyw","autonym":"Արեւմտահայերէն","dir":"ltr"},{"lang":"ia","autonym":"interlingua","dir":"ltr"},{"lang":"iba","autonym":"Jaku Iban","dir":"ltr"},{"lang":"ie","autonym":"Interlingue","dir":"ltr"},{"lang":"ig","autonym": "Igbo","dir":"ltr"},{"lang":"igl","autonym":"Igala","dir":"ltr"},{"lang":"ilo","autonym":"Ilokano","dir":"ltr"},{"lang":"io","autonym":"Ido","dir":"ltr"},{"lang":"it","autonym":"italiano","dir":"ltr"},{"lang":"iu","autonym":"ᐃᓄᒃᑎᑐᑦ / inuktitut","dir":"ltr"},{"lang":"jam","autonym":"Patois","dir":"ltr"},{"lang":"jv","autonym":"Jawa","dir":"ltr"},{"lang":"ka","autonym":"ქართული","dir":"ltr"},{"lang":"kaa","autonym":"Qaraqalpaqsha","dir":"ltr"},{"lang":"kab","autonym":"Taqbaylit","dir":"ltr"},{"lang":"kbd","autonym":"адыгэбзэ","dir":"ltr"},{"lang":"kbp","autonym":"Kabɩyɛ","dir":"ltr"},{"lang":"kcg","autonym":"Tyap","dir":"ltr"},{"lang":"kg","autonym":"Kongo","dir":"ltr"},{"lang":"kge","autonym":"Kumoring","dir":"ltr"},{"lang":"ki","autonym":"Gĩkũyũ","dir":"ltr"},{"lang":"kk","autonym":"қазақша","dir":"ltr"},{"lang":"kl","autonym":"kalaallisut","dir":"ltr"},{"lang":"km","autonym":"ភាសាខ្មែរ","dir":"ltr"},{"lang":"kn","autonym" :"ಕನ್ನಡ","dir":"ltr"},{"lang":"koi","autonym":"перем коми","dir":"ltr"},{"lang":"krc","autonym":"къарачай-малкъар","dir":"ltr"},{"lang":"ks","autonym":"कॉशुर / کٲشُر","dir":"rtl"},{"lang":"ku","autonym":"kurdî","dir":"ltr"},{"lang":"kus","autonym":"Kʋsaal","dir":"ltr"},{"lang":"kv","autonym":"коми","dir":"ltr"},{"lang":"kw","autonym":"kernowek","dir":"ltr"},{"lang":"ky","autonym":"кыргызча","dir":"ltr"},{"lang":"lad","autonym":"Ladino","dir":"ltr"},{"lang":"lb","autonym":"Lëtzebuergesch","dir":"ltr"},{"lang":"lez","autonym":"лезги","dir":"ltr"},{"lang":"lg","autonym":"Luganda","dir":"ltr"},{"lang":"li","autonym":"Limburgs","dir":"ltr"},{"lang":"lij","autonym":"Ligure","dir":"ltr"},{"lang":"lld","autonym":"Ladin","dir":"ltr"},{"lang":"lmo","autonym":"lombard","dir":"ltr"},{"lang":"ln","autonym":"lingála","dir":"ltr"},{"lang":"lo","autonym":"ລາວ","dir":"ltr"},{"lang":"lt","autonym":"lietuvių","dir":"ltr"},{ "lang":"ltg","autonym":"latgaļu","dir":"ltr"},{"lang":"lv","autonym":"latviešu","dir":"ltr"},{"lang":"mad","autonym":"Madhurâ","dir":"ltr"},{"lang":"mai","autonym":"मैथिली","dir":"ltr"},{"lang":"map-bms","autonym":"Basa Banyumasan","dir":"ltr"},{"lang":"mdf","autonym":"мокшень","dir":"ltr"},{"lang":"mg","autonym":"Malagasy","dir":"ltr"},{"lang":"mhr","autonym":"олык марий","dir":"ltr"},{"lang":"mi","autonym":"Māori","dir":"ltr"},{"lang":"min","autonym":"Minangkabau","dir":"ltr"},{"lang":"mk","autonym":"македонски","dir":"ltr"},{"lang":"ml","autonym":"മലയാളം","dir":"ltr"},{"lang":"mn","autonym":"монгол","dir":"ltr"},{"lang":"mni","autonym":"ꯃꯤꯇꯩ ꯂꯣꯟ","dir":"ltr"},{"lang":"mnw","autonym":"ဘာသာမန်","dir":"ltr"},{"lang":"mos","autonym":"moore","dir":"ltr"},{"lang":"mr","autonym":"मराठी","dir":"ltr"},{"lang":"mrj","autonym":"кырык мары","dir":"ltr"},{"lang":"ms","autonym": "Bahasa Melayu","dir":"ltr"},{"lang":"mt","autonym":"Malti","dir":"ltr"},{"lang":"mwl","autonym":"Mirandés","dir":"ltr"},{"lang":"my","autonym":"မြန်မာဘာသာ","dir":"ltr"},{"lang":"myv","autonym":"эрзянь","dir":"ltr"},{"lang":"mzn","autonym":"مازِرونی","dir":"rtl"},{"lang":"nah","autonym":"Nāhuatl","dir":"ltr"},{"lang":"nan","autonym":"閩南語 / Bân-lâm-gú","dir":"ltr"},{"lang":"nap","autonym":"Napulitano","dir":"ltr"},{"lang":"nb","autonym":"norsk bokmål","dir":"ltr"},{"lang":"nds","autonym":"Plattdüütsch","dir":"ltr"},{"lang":"nds-nl","autonym":"Nedersaksies","dir":"ltr"},{"lang":"ne","autonym":"नेपाली","dir":"ltr"},{"lang":"new","autonym":"नेपाल भाषा","dir":"ltr"},{"lang":"nia","autonym":"Li Niha","dir":"ltr"},{"lang":"nn","autonym":"norsk nynorsk","dir":"ltr"},{"lang":"nqo","autonym":"ߒߞߏ","dir":"rtl"},{"lang":"nr","autonym":"isiNdebele seSewula","dir":"ltr"},{"lang":"nso","autonym":"Sesotho sa Leboa","dir": "ltr"},{"lang":"ny","autonym":"Chi-Chewa","dir":"ltr"},{"lang":"oc","autonym":"occitan","dir":"ltr"},{"lang":"om","autonym":"Oromoo","dir":"ltr"},{"lang":"or","autonym":"ଓଡ଼ିଆ","dir":"ltr"},{"lang":"os","autonym":"ирон","dir":"ltr"},{"lang":"pa","autonym":"ਪੰਜਾਬੀ","dir":"ltr"},{"lang":"pag","autonym":"Pangasinan","dir":"ltr"},{"lang":"pam","autonym":"Kapampangan","dir":"ltr"},{"lang":"pap","autonym":"Papiamentu","dir":"ltr"},{"lang":"pcd","autonym":"Picard","dir":"ltr"},{"lang":"pcm","autonym":"Naijá","dir":"ltr"},{"lang":"pdc","autonym":"Deitsch","dir":"ltr"},{"lang":"pms","autonym":"Piemontèis","dir":"ltr"},{"lang":"pnb","autonym":"پنجابی","dir":"rtl"},{"lang":"ps","autonym":"پښتو","dir":"rtl"},{"lang":"pwn","autonym":"pinayuanan","dir":"ltr"},{"lang":"qu","autonym":"Runa Simi","dir":"ltr"},{"lang":"rm","autonym":"rumantsch","dir":"ltr"},{"lang":"rn","autonym":"ikirundi","dir":"ltr"},{"lang":"ro","autonym":"română","dir":"ltr"},{"lang":"rsk", "autonym":"руски","dir":"ltr"},{"lang":"rue","autonym":"русиньскый","dir":"ltr"},{"lang":"rup","autonym":"armãneashti","dir":"ltr"},{"lang":"rw","autonym":"Ikinyarwanda","dir":"ltr"},{"lang":"sa","autonym":"संस्कृतम्","dir":"ltr"},{"lang":"sah","autonym":"саха тыла","dir":"ltr"},{"lang":"sat","autonym":"ᱥᱟᱱᱛᱟᱲᱤ","dir":"ltr"},{"lang":"sc","autonym":"sardu","dir":"ltr"},{"lang":"scn","autonym":"sicilianu","dir":"ltr"},{"lang":"sco","autonym":"Scots","dir":"ltr"},{"lang":"sd","autonym":"سنڌي","dir":"rtl"},{"lang":"se","autonym":"davvisámegiella","dir":"ltr"},{"lang":"sg","autonym":"Sängö","dir":"ltr"},{"lang":"sgs","autonym":"žemaitėška","dir":"ltr"},{"lang":"sh","autonym":"srpskohrvatski / српскохрватски","dir":"ltr"},{"lang":"shi","autonym":"Taclḥit","dir":"ltr"},{"lang":"shn","autonym":"ၽႃႇသႃႇတႆး ","dir":"ltr"},{"lang":"si","autonym":"සිංහල","dir":"ltr"},{"lang":"sk","autonym": "slovenčina","dir":"ltr"},{"lang":"skr","autonym":"سرائیکی","dir":"rtl"},{"lang":"sl","autonym":"slovenščina","dir":"ltr"},{"lang":"sm","autonym":"Gagana Samoa","dir":"ltr"},{"lang":"smn","autonym":"anarâškielâ","dir":"ltr"},{"lang":"sn","autonym":"chiShona","dir":"ltr"},{"lang":"so","autonym":"Soomaaliga","dir":"ltr"},{"lang":"sq","autonym":"shqip","dir":"ltr"},{"lang":"sr","autonym":"српски / srpski","dir":"ltr"},{"lang":"srn","autonym":"Sranantongo","dir":"ltr"},{"lang":"ss","autonym":"SiSwati","dir":"ltr"},{"lang":"st","autonym":"Sesotho","dir":"ltr"},{"lang":"stq","autonym":"Seeltersk","dir":"ltr"},{"lang":"su","autonym":"Sunda","dir":"ltr"},{"lang":"sw","autonym":"Kiswahili","dir":"ltr"},{"lang":"szl","autonym":"ślůnski","dir":"ltr"},{"lang":"ta","autonym":"தமிழ்","dir":"ltr"},{"lang":"tay","autonym":"Tayal","dir":"ltr"},{"lang":"tcy","autonym":"ತುಳು","dir":"ltr"},{"lang":"tdd","autonym":"ᥖᥭᥰ ᥖᥬᥲ ᥑᥨᥒᥰ","dir":"ltr"},{ "lang":"te","autonym":"తెలుగు","dir":"ltr"},{"lang":"tet","autonym":"tetun","dir":"ltr"},{"lang":"tg","autonym":"тоҷикӣ","dir":"ltr"},{"lang":"th","autonym":"ไทย","dir":"ltr"},{"lang":"ti","autonym":"ትግርኛ","dir":"ltr"},{"lang":"tk","autonym":"Türkmençe","dir":"ltr"},{"lang":"tl","autonym":"Tagalog","dir":"ltr"},{"lang":"tly","autonym":"tolışi","dir":"ltr"},{"lang":"tn","autonym":"Setswana","dir":"ltr"},{"lang":"to","autonym":"lea faka-Tonga","dir":"ltr"},{"lang":"tpi","autonym":"Tok Pisin","dir":"ltr"},{"lang":"tr","autonym":"Türkçe","dir":"ltr"},{"lang":"trv","autonym":"Seediq","dir":"ltr"},{"lang":"ts","autonym":"Xitsonga","dir":"ltr"},{"lang":"tt","autonym":"татарча / tatarça","dir":"ltr"},{"lang":"tum","autonym":"chiTumbuka","dir":"ltr"},{"lang":"tw","autonym":"Twi","dir":"ltr"},{"lang":"ty","autonym":"reo tahiti","dir":"ltr"},{"lang":"tyv","autonym":"тыва дыл","dir":"ltr"},{"lang":"udm","autonym":"удмурт","dir":"ltr"},{ "lang":"ur","autonym":"اردو","dir":"rtl"},{"lang":"uz","autonym":"oʻzbekcha / ўзбекча","dir":"ltr"},{"lang":"ve","autonym":"Tshivenda","dir":"ltr"},{"lang":"vec","autonym":"vèneto","dir":"ltr"},{"lang":"vep","autonym":"vepsän kel’","dir":"ltr"},{"lang":"vi","autonym":"Tiếng Việt","dir":"ltr"},{"lang":"vls","autonym":"West-Vlams","dir":"ltr"},{"lang":"vo","autonym":"Volapük","dir":"ltr"},{"lang":"vro","autonym":"võro","dir":"ltr"},{"lang":"wa","autonym":"walon","dir":"ltr"},{"lang":"war","autonym":"Winaray","dir":"ltr"},{"lang":"wo","autonym":"Wolof","dir":"ltr"},{"lang":"wuu","autonym":"吴语","dir":"ltr"},{"lang":"xal","autonym":"хальмг","dir":"ltr"},{"lang":"xh","autonym":"isiXhosa","dir":"ltr"},{"lang":"xmf","autonym":"მარგალური","dir":"ltr"},{"lang":"yi","autonym":"ייִדיש","dir":"rtl"},{"lang":"yo","autonym":"Yorùbá","dir":"ltr"},{"lang":"yue","autonym":"粵語","dir":"ltr"},{"lang":"za","autonym":"Vahcuengh","dir":"ltr"},{ "lang":"zgh","autonym":"ⵜⴰⵎⴰⵣⵉⵖⵜ ⵜⴰⵏⴰⵡⴰⵢⵜ","dir":"ltr"},{"lang":"zu","autonym":"isiZulu","dir":"ltr"}],"wgSectionTranslationTargetLanguages":["ace","ady","alt","am","ami","an","ang","ann","anp","ar","ary","arz","as","ast","av","avk","awa","ay","az","azb","ba","ban","bar","bbc","bcl","bdr","be","bew","bg","bho","bi","bjn","blk","bm","bn","bo","bpy","br","bs","btm","bug","ca","cdo","ce","ceb","ch","chr","ckb","co","cr","crh","cs","cu","cy","da","dag","de","dga","din","diq","dsb","dtp","dv","dz","ee","el","eml","eo","es","et","eu","fa","fat","ff","fi","fj","fo","fon","fr","frp","frr","fur","fy","gag","gan","gcr","gl","glk","gn","gom","gor","gpe","gu","guc","gur","guw","gv","ha","hak","haw","he","hi","hif","hr","hsb","ht","hu","hy","hyw","ia","iba","ie","ig","igl","ilo","io","is","it","iu","ja","jam","jv","ka","kaa","kab","kbd","kbp","kcg","kg","kge","ki","kk","kl","km","kn","ko","koi","krc","ks","ku","kus","kv","kw","ky","lad","lb","lez","lg","li","lij", "lld","lmo","ln","lo","lt","ltg","lv","mad","mai","map-bms","mdf","mg","mhr","mi","min","mk","ml","mn","mni","mnw","mos","mr","mrj","ms","mt","mwl","my","myv","mzn","nah","nan","nap","nb","nds","nds-nl","ne","new","nia","nl","nn","nqo","nr","nso","ny","oc","om","or","os","pa","pag","pam","pap","pcd","pcm","pdc","pl","pms","pnb","ps","pt","pwn","qu","rm","rn","ro","rsk","rue","rup","rw","sa","sah","sat","sc","scn","sco","sd","se","sg","sgs","sh","shi","shn","si","sk","skr","sl","sm","smn","sn","so","sq","sr","srn","ss","st","stq","su","sv","sw","szl","ta","tay","tcy","tdd","te","tet","tg","th","ti","tk","tl","tly","tn","to","tpi","tr","trv","ts","tt","tum","tw","ty","tyv","udm","ur","uz","ve","vec","vep","vi","vls","vo","vro","wa","war","wo","wuu","xal","xh","xmf","yi","yo","yue","za","zgh","zh","zu"],"isLanguageSearcherCXEntrypointEnabled":true,"mintEntrypointLanguages":["ace","ast","azb","bcl","bjn","bh","crh","ff","fon","ig","is","ki","ks","lmo","min","sat","ss","tn","vec"], "wgWikibaseItemId":"Q760170","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false,"wgMinervaPermissions":{"watchable":true,"watch":false},"wgMinervaFeatures":{"beta":false,"donate":true,"mobileOptionsLink":true,"categories":false,"pageIssues":true,"talkAtTop":true,"historyInPageActions":false,"overflowSubmenu":false,"tabsOnSpecials":true,"personalMenu":false,"mainMenuExpanded":false,"echo":true,"nightMode":true},"wgMinervaDownloadNamespaces":[0]};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.math.styles":"ready","ext.pygments":"ready","ext.cite.styles":"ready","skins.minerva.styles":"ready", "skins.minerva.content.styles.images":"ready","mediawiki.hlist":"ready","skins.minerva.codex.styles":"ready","skins.minerva.icons":"ready","skins.minerva.amc.styles":"ready","ext.wikimediamessages.styles":"ready","mobile.init.styles":"ready","ext.relatedArticles.styles":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.pygments.view","ext.cite.ux-enhancements","site","mediawiki.page.ready","skins.minerva.scripts","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","ext.popups","mobile.init","ext.echo.centralauth","ext.relatedArticles.readMore.bootstrap","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.cx.eventlogging.campaigns","ext.cx.entrypoints.mffrequentlanguages","ext.cx.entrypoints.languagesearcher.init","mw.externalguidance.init","ext.checkUser.clientHints","ext.growthExperiments.SuggestedEditSession","wikibase.sidebar.tracking"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&modules=ext.cite.styles%7Cext.math.styles%7Cext.pygments%2CwikimediaBadges%7Cext.relatedArticles.styles%7Cext.wikimediamessages.styles%7Cmediawiki.hlist%7Cmobile.init.styles%7Cskins.minerva.amc.styles%7Cskins.minerva.codex.styles%7Cskins.minerva.content.styles.images%7Cskins.minerva.icons%2Cstyles%7Cwikibase.client.init&only=styles&skin=minerva"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=minerva"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=minerva"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="theme-color" content="#eaecf0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0"> <meta property="og:title" content="Enumerated type - Wikipedia"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="manifest" href="/w/api.php?action=webapp-manifest"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Enumerated_type&action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/Enumerated_type"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Enumerated_type rootpage-Enumerated_type stable issues-group-B skin-minerva action-view skin--responsive mw-mf-amc-disabled mw-mf"><div id="mw-mf-viewport"> <div id="mw-mf-page-center"> <a class="mw-mf-page-center__mask" href="#"></a> <header class="header-container header-chrome"> <div class="minerva-header"> <nav class="navigation-drawer toggle-list view-border-box"> <input type="checkbox" id="main-menu-input" class="toggle-list__checkbox" role="button" aria-haspopup="true" aria-expanded="false" aria-labelledby="mw-mf-main-menu-button"> <label role="button" for="main-menu-input" id="mw-mf-main-menu-button" aria-hidden="true" data-event-name="ui.mainmenu" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet toggle-list__toggle"> <span class="minerva-icon minerva-icon--menu"></span> <span></span> </label> <div id="mw-mf-page-left" class="menu view-border-box"> <ul id="p-navigation" class="toggle-list__list"> <li class="toggle-list-item "> <a class="toggle-list-item__anchor menu__item--home" href="/wiki/Main_Page" data-mw="interface"> <span class="minerva-icon minerva-icon--home"></span> <span class="toggle-list-item__label">Home</span> </a> </li> <li class="toggle-list-item "> <a class="toggle-list-item__anchor menu__item--random" href="/wiki/Special:Random" data-mw="interface"> <span class="minerva-icon minerva-icon--die"></span> <span class="toggle-list-item__label">Random</span> </a> </li> <li class="toggle-list-item skin-minerva-list-item-jsonly"> <a class="toggle-list-item__anchor menu__item--nearby" href="/wiki/Special:Nearby" data-event-name="menu.nearby" data-mw="interface"> <span class="minerva-icon minerva-icon--mapPin"></span> <span class="toggle-list-item__label">Nearby</span> </a> </li> </ul> <ul id="p-personal" class="toggle-list__list"> <li class="toggle-list-item "> <a class="toggle-list-item__anchor menu__item--login" href="/w/index.php?title=Special:UserLogin&returnto=Enumerated+type" data-event-name="menu.login" data-mw="interface"> <span class="minerva-icon minerva-icon--logIn"></span> <span class="toggle-list-item__label">Log in</span> </a> </li> </ul> <ul id="pt-preferences" class="toggle-list__list"> <li class="toggle-list-item skin-minerva-list-item-jsonly"> <a class="toggle-list-item__anchor menu__item--settings" href="/w/index.php?title=Special:MobileOptions&returnto=Enumerated+type" data-event-name="menu.settings" data-mw="interface"> <span class="minerva-icon minerva-icon--settings"></span> <span class="toggle-list-item__label">Settings</span> </a> </li> </ul> <ul id="p-donation" class="toggle-list__list"> <li class="toggle-list-item "> <a class="toggle-list-item__anchor menu__item--donate" href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en&utm_key=minerva" data-event-name="menu.donate" data-mw="interface"> <span class="minerva-icon minerva-icon--heart"></span> <span class="toggle-list-item__label">Donate</span> </a> </li> </ul> <ul class="hlist"> <li class="toggle-list-item "> <a class="toggle-list-item__anchor menu__item--about" href="/wiki/Wikipedia:About" data-mw="interface"> <span class="toggle-list-item__label">About Wikipedia</span> </a> </li> <li class="toggle-list-item "> <a class="toggle-list-item__anchor menu__item--disclaimers" href="/wiki/Wikipedia:General_disclaimer" data-mw="interface"> <span class="toggle-list-item__label">Disclaimers</span> </a> </li> </ul> </div> <label class="main-menu-mask" for="main-menu-input"></label> </nav> <div class="branding-box"> <a href="/wiki/Main_Page"> <span><img src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" alt="Wikipedia" width="120" height="18" style="width: 7.5em; height: 1.125em;"/> </span> </a> </div> <form action="/w/index.php" method="get" class="minerva-search-form"> <div class="search-box"> <input type="hidden" name="title" value="Special:Search"/> <input class="search skin-minerva-search-trigger" id="searchInput" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f"> <span class="search-box-icon-overlay"><span class="minerva-icon minerva-icon--search"></span> </span> </div> <button id="searchIcon" class="cdx-button cdx-button--size-large cdx-button--icon-only cdx-button--weight-quiet skin-minerva-search-trigger"> <span class="minerva-icon minerva-icon--search"></span> <span>Search</span> </button> </form> <nav class="minerva-user-navigation" aria-label="User navigation"> </nav> </div> </header> <main id="content" class="mw-body"> <div class="banner-container"> <div id="siteNotice"></div> </div> <div class="pre-content heading-holder"> <div class="page-heading"> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Enumerated type</span></h1> <div class="tagline"></div> </div> <ul id="p-associated-pages" class="minerva__tab-container"> <li class="minerva__tab selected"> <a class="minerva__tab-text" href="/wiki/Enumerated_type" rel="" data-event-name="tabs.subject">Article</a> </li> <li class="minerva__tab "> <a class="minerva__tab-text" href="/wiki/Talk:Enumerated_type" rel="discussion" data-event-name="tabs.talk">Talk</a> </li> </ul> <nav class="page-actions-menu"> <ul id="p-views" class="page-actions-menu__list"> <li id="language-selector" class="page-actions-menu__list-item"> <a role="button" href="#p-lang" data-mw="interface" data-event-name="menu.languages" title="Language" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet language-selector"> <span class="minerva-icon minerva-icon--language"></span> <span>Language</span> </a> </li> <li id="page-actions-watch" class="page-actions-menu__list-item"> <a role="button" id="ca-watch" href="/w/index.php?title=Special:UserLogin&returnto=Enumerated+type" data-event-name="menu.watch" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet menu__item--page-actions-watch"> <span class="minerva-icon minerva-icon--star"></span> <span>Watch</span> </a> </li> <li id="page-actions-edit" class="page-actions-menu__list-item"> <a role="button" id="ca-edit" href="/w/index.php?title=Enumerated_type&action=edit" data-event-name="menu.edit" data-mw="interface" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet edit-page menu__item--page-actions-edit"> <span class="minerva-icon minerva-icon--edit"></span> <span>Edit</span> </a> </li> </ul> </nav> <!-- version 1.0.2 (change every time you update a partial) --> <div id="mw-content-subtitle"></div> </div> <div id="bodyContent" class="content"> <div id="mw-content-text" class="mw-body-content"><script>function mfTempOpenSection(id){var block=document.getElementById("mf-section-"+id);block.className+=" open-block";block.previousSibling.className+=" open-block";}</script><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><section class="mf-section-0" id="mf-section-0"> <p>In <a href="/wiki/Computer_programming" title="Computer programming">computer programming</a>, an <b>enumerated type</b> (also called <b>enumeration</b>, <b>enum</b>, or <b>factor</b> in the <a href="/wiki/R_(programming_language)" title="R (programming language)">R programming language</a>, and a <a href="/wiki/Categorical_variable" title="Categorical variable">categorical variable</a> in statistics) is a <a href="/wiki/Data_type" title="Data type">data type</a> consisting of a set of named <a href="/wiki/Value_(computer_science)" title="Value (computer science)">values</a> called <i>elements</i>, <i>members</i>, <i>enumeral</i>, or <i>enumerators</i> of the type. The enumerator names are usually <a href="/wiki/Identifier_(computer_languages)" title="Identifier (computer languages)">identifiers</a> that behave as <a href="/wiki/Constant_(programming)" class="mw-redirect" title="Constant (programming)">constants</a> in the language. An enumerated type can be seen as a degenerate <a href="/wiki/Tagged_union" title="Tagged union">tagged union</a> of <a href="/wiki/Unit_type" title="Unit type">unit type</a>. A <a href="/wiki/Variable_(computer_science)" title="Variable (computer science)">variable</a> that has been <a href="/wiki/Declaration_(computer_science)" class="mw-redirect" title="Declaration (computer science)">declared</a> as having an enumerated type can be assigned any of the enumerators as a value. In other words, an enumerated type has values that are different from each other, and that can be compared and assigned, but are not specified by the programmer as having any particular concrete representation in the computer's memory; compilers and interpreters can represent them arbitrarily. </p> <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">1</span> <span class="toctext">Description</span></a></li> <li class="toclevel-1 tocsection-2"><a href="#Rationale"><span class="tocnumber">2</span> <span class="toctext">Rationale</span></a></li> <li class="toclevel-1 tocsection-3"><a href="#Conventions"><span class="tocnumber">3</span> <span class="toctext">Conventions</span></a></li> <li class="toclevel-1 tocsection-4"><a href="#Syntax_in_several_programming_languages"><span class="tocnumber">4</span> <span class="toctext">Syntax in several programming languages</span></a> <ul> <li class="toclevel-2 tocsection-5"><a href="#Pascal_and_syntactically_similar_languages"><span class="tocnumber">4.1</span> <span class="toctext">Pascal and syntactically similar languages</span></a> <ul> <li class="toclevel-3 tocsection-6"><a href="#Pascal"><span class="tocnumber">4.1.1</span> <span class="toctext">Pascal</span></a></li> <li class="toclevel-3 tocsection-7"><a href="#Ada"><span class="tocnumber">4.1.2</span> <span class="toctext">Ada</span></a></li> </ul> </li> <li class="toclevel-2 tocsection-8"><a href="#C_and_syntactically_similar_languages"><span class="tocnumber">4.2</span> <span class="toctext">C and syntactically similar languages</span></a> <ul> <li class="toclevel-3 tocsection-9"><a href="#C"><span class="tocnumber">4.2.1</span> <span class="toctext">C</span></a></li> <li class="toclevel-3 tocsection-10"><a href="#C#"><span class="tocnumber">4.2.2</span> <span class="toctext">C#</span></a></li> <li class="toclevel-3 tocsection-11"><a href="#C++"><span class="tocnumber">4.2.3</span> <span class="toctext">C++</span></a></li> <li class="toclevel-3 tocsection-12"><a href="#Go"><span class="tocnumber">4.2.4</span> <span class="toctext">Go</span></a></li> <li class="toclevel-3 tocsection-13"><a href="#Haxe"><span class="tocnumber">4.2.5</span> <span class="toctext">Haxe</span></a></li> <li class="toclevel-3 tocsection-14"><a href="#Java"><span class="tocnumber">4.2.6</span> <span class="toctext">Java</span></a></li> <li class="toclevel-3 tocsection-15"><a href="#Perl"><span class="tocnumber">4.2.7</span> <span class="toctext">Perl</span></a></li> <li class="toclevel-3 tocsection-16"><a href="#Raku"><span class="tocnumber">4.2.8</span> <span class="toctext">Raku</span></a></li> <li class="toclevel-3 tocsection-17"><a href="#PHP"><span class="tocnumber">4.2.9</span> <span class="toctext">PHP</span></a></li> <li class="toclevel-3 tocsection-18"><a href="#Rust"><span class="tocnumber">4.2.10</span> <span class="toctext">Rust</span></a></li> <li class="toclevel-3 tocsection-19"><a href="#Swift"><span class="tocnumber">4.2.11</span> <span class="toctext">Swift</span></a></li> <li class="toclevel-3 tocsection-20"><a href="#TypeScript"><span class="tocnumber">4.2.12</span> <span class="toctext">TypeScript</span></a></li> <li class="toclevel-3 tocsection-21"><a href="#Python"><span class="tocnumber">4.2.13</span> <span class="toctext">Python</span></a></li> <li class="toclevel-3 tocsection-22"><a href="#Fortran"><span class="tocnumber">4.2.14</span> <span class="toctext">Fortran</span></a></li> <li class="toclevel-3 tocsection-23"><a href="#Visual_Basic/VBA"><span class="tocnumber">4.2.15</span> <span class="toctext">Visual Basic/VBA</span></a></li> <li class="toclevel-3 tocsection-24"><a href="#Lisp"><span class="tocnumber">4.2.16</span> <span class="toctext">Lisp</span></a></li> <li class="toclevel-3 tocsection-25"><a href="#Dart"><span class="tocnumber">4.2.17</span> <span class="toctext">Dart</span></a></li> </ul> </li> </ul> </li> <li class="toclevel-1 tocsection-26"><a href="#Algebraic_data_type_in_functional_programming"><span class="tocnumber">5</span> <span class="toctext">Algebraic data type in functional programming</span></a></li> <li class="toclevel-1 tocsection-27"><a href="#Databases"><span class="tocnumber">6</span> <span class="toctext">Databases</span></a></li> <li class="toclevel-1 tocsection-28"><a href="#XML_Schema"><span class="tocnumber">7</span> <span class="toctext">XML Schema</span></a></li> <li class="toclevel-1 tocsection-29"><a href="#See_also"><span class="tocnumber">8</span> <span class="toctext">See also</span></a></li> <li class="toclevel-1 tocsection-30"><a href="#References"><span class="tocnumber">9</span> <span class="toctext">References</span></a></li> <li class="toclevel-1 tocsection-31"><a href="#External_links"><span class="tocnumber">10</span> <span class="toctext">External links</span></a></li> </ul> </div> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(1)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="Description">Description</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=1" title="Edit section: Description" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-1 collapsible-block" id="mf-section-1"> <p>For example, the four <a href="/wiki/Suit_(cards)" class="mw-redirect" title="Suit (cards)">suits</a> in a deck of playing cards may be four enumerators named <i>Club</i>, <i>Diamond</i>, <i>Heart</i>, and <i>Spade</i>, belonging to an enumerated type named <i>suit</i>. If a variable <i>V</i> is declared having <i>suit</i> as its data type, one can assign any of those four values to it. </p><p>Although the enumerators are usually distinct, some languages may allow the same enumerator to be listed twice in the type's declaration. The names of enumerators need not be semantically complete or compatible in any sense. For example, an enumerated type called <i>color</i> may be defined to consist of the enumerators <i>Red</i>, <i>Green</i>, <i>Zebra</i>, <i>Missing</i>, and <i>Bacon</i>. In some languages, the declaration of an enumerated type also intentionally defines an <a href="/wiki/Total_order" title="Total order">ordering</a> of its members (<i>High</i>, <i>Medium</i> and <i>Low</i> priorities); in others, the enumerators are unordered (<i>English</i>, <i>French</i>, <i>German</i> and <i>Spanish</i> supported languages); in others still, an implicit ordering arises from the compiler concretely representing enumerators as integers. </p><p>Some enumerator types may be <a href="/wiki/Built-in_type" class="mw-redirect" title="Built-in type">built into</a> the language. The <a href="/wiki/Boolean_type" class="mw-redirect" title="Boolean type">Boolean type</a>, for example is often a pre-defined enumeration of the values <i>False</i> and <i>True</i>. A unit type consisting of a single value may also be defined to represent <i>null</i>. Many languages allow users to define new enumerated types. </p><p>Values and variables of an enumerated type are usually implemented with some <a href="/wiki/Integer_(computer_science)" title="Integer (computer science)">integer</a> type as the underlying representation. Some languages, especially <a href="/wiki/System_programming_language" title="System programming language">system programming languages</a>, allow the user to specify the bit combination to be used for each enumerator, which can be useful to efficiently represent sets of enumerators as fixed-length bit strings. In <a href="/wiki/Type_theory" title="Type theory">type theory</a>, enumerated types are often regarded as <a href="/wiki/Tagged_union" title="Tagged union">tagged unions</a> of <a href="/wiki/Unit_type" title="Unit type">unit types</a>. Since such types are of the form <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1+1+\cdots +1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mn>1</mn> <mo>+</mo> <mn>1</mn> <mo>+</mo> <mo>⋯<!-- ⋯ --></mo> <mo>+</mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 1+1+\cdots +1}</annotation> </semantics> </math></span><noscript><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/fe420bc40161e1c9af002a820411964f7841c085" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:14.732ex; height:2.343ex;" alt="{\displaystyle 1+1+\cdots +1}"></noscript><span class="lazy-image-placeholder" style="width: 14.732ex;height: 2.343ex;vertical-align: -0.505ex;" data-src="https://wikimedia.org/api/rest_v1/media/math/render/svg/fe420bc40161e1c9af002a820411964f7841c085" data-alt="{\displaystyle 1+1+\cdots +1}" data-class="mwe-math-fallback-image-inline mw-invert skin-invert"> </span></span>, they may also be written as natural numbers. </p> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(2)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="Rationale">Rationale</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=2" title="Edit section: Rationale" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-2 collapsible-block" id="mf-section-2"> <p>Some early programming languages did not originally have enumerated types. If a programmer wanted a variable, for example <i>myColor</i>, to have a value of red, the variable red would be declared and assigned some arbitrary value, usually an integer constant. The variable red would then be assigned to <i>myColor</i>. Other techniques assigned arbitrary values to strings containing the names of the enumerators. </p><p>These arbitrary values were sometimes referred to as <a href="/wiki/Magic_number_(programming)" title="Magic number (programming)">magic numbers</a> since there often was no explanation as to how the numbers were obtained or whether their actual values were significant. These magic numbers could make the source code harder for others to understand and maintain. </p><p>Enumerated types, on the other hand, make the code more self-documenting. Depending on the language, the compiler could automatically assign default values to the enumerators thereby hiding unnecessary detail from the programmer. These values may not even be visible to the programmer (see <a href="/wiki/Information_hiding" title="Information hiding">information hiding</a>). Enumerated types can also prevent a programmer from writing illogical code such as performing mathematical operations on the values of the enumerators. If the value of a variable that was assigned an enumerator were to be printed, some programming languages could also print the name of the enumerator rather than its underlying numerical value. A further advantage is that enumerated types can allow compilers to enforce semantic correctness. For instance: <code>myColor = TRIANGLE</code> can be forbidden, whilst <code>myColor = RED</code> is accepted, even if <i>TRIANGLE</i> and <i>RED</i> are both internally represented as <i>1</i>. </p><p>Conceptually, an enumerated type is similar to a list of <a href="/wiki/Nominal_number" title="Nominal number">nominals</a> (numeric codes), since each possible value of the type is assigned a distinctive natural number. A given enumerated type is thus a concrete implementation of this notion. When order is meaningful and/or used for comparison, then an enumerated type becomes an <a href="/wiki/Ordinal_number" title="Ordinal number">ordinal</a> type. </p> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(3)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="Conventions">Conventions</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=3" title="Edit section: Conventions" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-3 collapsible-block" id="mf-section-3"> <p><a href="/wiki/Programming_languages" class="mw-redirect" title="Programming languages">Programming languages</a> tend to have their own, oftentimes multiple, <a href="/wiki/Programming_styles" class="mw-redirect" title="Programming styles">programming styles</a> and <a href="/wiki/Naming_convention_(programming)" title="Naming convention (programming)">naming conventions</a>. The variable assigned to an enumeration is usually a noun in singular form, and frequently follows either a <a href="/wiki/PascalCase" class="mw-redirect" title="PascalCase">PascalCase</a> or <a href="/wiki/Uppercase" class="mw-redirect" title="Uppercase">uppercase</a> convention, while <a href="/wiki/Lowercase" class="mw-redirect" title="Lowercase">lowercase</a> and others are seen less frequently. </p> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(4)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="Syntax_in_several_programming_languages">Syntax in several programming languages</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=4" title="Edit section: Syntax in several programming languages" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-4 collapsible-block" id="mf-section-4"> <div class="mw-heading mw-heading3"><h3 id="Pascal_and_syntactically_similar_languages">Pascal and syntactically similar languages</h3><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=5" title="Edit section: Pascal and syntactically similar languages" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <div class="mw-heading mw-heading4"><h4 id="Pascal">Pascal</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=6" title="Edit section: Pascal" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>In <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>, an enumerated type can be implicitly declared by listing the values in a parenthesised list: </p> <div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="k">var</span> <span class="w"> </span><span class="n">suit</span><span class="o">:</span><span class="w"> </span><span class="p">(</span><span class="n">clubs</span><span class="o">,</span><span class="w"> </span><span class="n">diamonds</span><span class="o">,</span><span class="w"> </span><span class="n">hearts</span><span class="o">,</span><span class="w"> </span><span class="n">spades</span><span class="p">)</span><span class="o">;</span> </pre></div> <p>The declaration will often appear in a type synonym declaration, such that it can be used for multiple variables: </p> <div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="k">type</span> <span class="w"> </span><span class="n">cardsuit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">clubs</span><span class="o">,</span><span class="w"> </span><span class="n">diamonds</span><span class="o">,</span><span class="w"> </span><span class="n">hearts</span><span class="o">,</span><span class="w"> </span><span class="n">spades</span><span class="p">)</span><span class="o">;</span> <span class="w"> </span><span class="n">card</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">record</span> <span class="w"> </span><span class="n">suit</span><span class="o">:</span><span class="w"> </span><span class="n">cardsuit</span><span class="o">;</span> <span class="w"> </span><span class="n">value</span><span class="o">:</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="mi">13</span><span class="o">;</span> <span class="w"> </span><span class="k">end</span><span class="o">;</span> <span class="w"> </span><span class="k">var</span> <span class="w"> </span><span class="n">hand</span><span class="o">:</span><span class="w"> </span><span class="k">array</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="mi">13</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="k">of</span><span class="w"> </span><span class="n">card</span><span class="o">;</span> <span class="w"> </span><span class="n">trump</span><span class="o">:</span><span class="w"> </span><span class="n">cardsuit</span><span class="o">;</span> </pre></div> <p>The order in which the enumeration values are given matters. An enumerated type is an ordinal type, and the <code>pred</code> and <code>succ</code> functions will give the prior or next value of the enumeration, and <code>ord</code> can convert enumeration values to their integer representation. Standard Pascal does not offer a conversion from arithmetic types to enumerations, however. Extended Pascal offers this functionality via an extended <code>succ</code> function. Some other Pascal dialects allow it via type-casts. Some modern descendants of Pascal, such as <a href="/wiki/Modula-3" title="Modula-3">Modula-3</a>, provide a special conversion syntax using a method called <code>VAL</code>; Modula-3 also treats <code>BOOLEAN</code> and <code>CHAR</code> as special pre-defined enumerated types and uses <code>ORD</code> and <code>VAL</code> for standard ASCII decoding and encoding. </p><p>Pascal style languages also allow enumeration to be used as array index: </p> <div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="k">var</span> <span class="w"> </span><span class="n">suitcount</span><span class="o">:</span><span class="w"> </span><span class="k">array</span><span class="w"> </span><span class="p">[</span><span class="n">cardsuit</span><span class="p">]</span><span class="w"> </span><span class="k">of</span><span class="w"> </span><span class="kt">integer</span><span class="o">;</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Ada">Ada</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=7" title="Edit section: Ada" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>In <a href="/wiki/Ada_(programming_language)" title="Ada (programming language)">Ada</a>, the use of "=" was replaced with "is" leaving the definition quite similar: </p> <div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">type</span> <span class="kt">Cardsuit</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">clubs</span><span class="p">,</span> <span class="nv">diamonds</span><span class="p">,</span> <span class="nv">hearts</span><span class="p">,</span> <span class="nv">spades</span><span class="p">);</span> </pre></div> <p>In addition to <code>Pred</code>, <code>Succ</code>, <code>Val</code> and <code>Pos</code> Ada also supports simple string conversions via <code>Image</code> and <code>Value</code>. </p><p>Similar to C-style languages Ada allows the internal representation of the enumeration to be specified: </p> <div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">for</span> <span class="n">Cardsuit</span> <span class="kn">use</span> <span class="p">(</span><span class="n">clubs</span> <span class="p">=></span> <span class="mi">1</span><span class="p">,</span> <span class="n">diamonds</span> <span class="p">=></span> <span class="mi">2</span><span class="p">,</span> <span class="n">hearts</span> <span class="p">=></span> <span class="mi">4</span><span class="p">,</span> <span class="n">spades</span> <span class="p">=></span> <span class="mi">8</span><span class="p">);</span> </pre></div> <p>Unlike C-style languages Ada also allows the number of bits of the enumeration to be specified: </p> <div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">for</span> <span class="n">Cardsuit</span><span class="p">'</span><span class="na">Size</span> <span class="kn">use</span> <span class="n">4</span><span class="p">;</span> <span class="c1">-- 4 bits</span> </pre></div> <p>Additionally, one can use enumerations as indexes for arrays, like in Pascal, but there are attributes defined for enumerations </p> <div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span> <span class="no">Shuffle</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kr">array</span><span class="p">(</span><span class="n">Cardsuit</span><span class="p">)</span> <span class="kr">of</span> <span class="n">Cardsuit</span> <span class="p">:=</span> <span class="p">(</span><span class="n">Clubs</span> <span class="p">=></span> <span class="n">Cardsuit</span><span class="p">'</span><span class="na">Succ</span><span class="p">(</span><span class="n">Clubs</span><span class="p">),</span> <span class="c1">-- see attributes of enumerations 'First, 'Last, 'Succ, 'Pred</span> <span class="n">Diamonds</span> <span class="p">=></span> <span class="n">Hearts</span><span class="p">,</span> <span class="c1">--an explicit value</span> <span class="n">Hearts</span> <span class="p">=></span> <span class="n">Cardsuit</span><span class="p">'</span><span class="na">Last</span><span class="p">,</span> <span class="c1">--first enumeration value of type Cardsuit e.g., clubs</span> <span class="n">Spades</span> <span class="p">=></span> <span class="n">Cardsuit</span><span class="p">'</span><span class="na">First</span> <span class="c1">--last enumeration value of type Cardsuit e.g., spades</span> <span class="p">);</span> </pre></div> <p>Like <a href="/wiki/Modula-3" title="Modula-3">Modula-3</a> Ada treats <code>Boolean</code> and <code>Character</code> as special pre-defined (in package "<code>Standard</code>") enumerated types. Unlike Modula-3 one can also define own character types: </p> <div class="mw-highlight mw-highlight-lang-ada mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">type</span> <span class="kt">Cards</span> <span class="kr">is</span> <span class="p">('</span><span class="na">7</span><span class="p">',</span> <span class="p">'</span><span class="na">8</span><span class="p">',</span> <span class="p">'</span><span class="na">9</span><span class="p">',</span> <span class="p">'</span><span class="na">J</span><span class="p">',</span> <span class="p">'</span><span class="na">Q</span><span class="p">',</span> <span class="p">'</span><span class="na">K</span><span class="p">',</span> <span class="p">'</span><span class="na">A</span><span class="p">');</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="C_and_syntactically_similar_languages">C and syntactically similar languages</h3><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=8" title="Edit section: C and syntactically similar languages" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <div class="mw-heading mw-heading4"><h4 id="C">C</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=9" title="Edit section: C" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>The original <a href="/wiki/K%26R_C" class="mw-redirect" title="K&R C">K&R</a> dialect of the programming language <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> had no enumerated types.<sup id="cite_ref-k&r1e_1-0" class="reference"><a href="#cite_note-k&r1e-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> In C, enumerations are created by explicit definitions (the <code>enum</code> keyword by itself does not cause allocation of storage) which use the <code>enum</code> keyword and are reminiscent of <a href="/wiki/Struct_(C_programming_language)" title="Struct (C programming language)">struct</a> and <a href="/wiki/Union_type" title="Union type">union</a> definitions: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span><span class="w"> </span><span class="n">cardsuit</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Clubs</span><span class="p">,</span> <span class="w"> </span><span class="n">Diamonds</span><span class="p">,</span> <span class="w"> </span><span class="n">Hearts</span><span class="p">,</span> <span class="w"> </span><span class="n">Spades</span> <span class="p">};</span> <span class="k">struct</span><span class="w"> </span><span class="nc">card</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">enum</span><span class="w"> </span><span class="n">cardsuit</span><span class="w"> </span><span class="n">suit</span><span class="p">;</span> <span class="w"> </span><span class="kt">short</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">value</span><span class="p">;</span> <span class="p">}</span><span class="w"> </span><span class="n">hand</span><span class="p">[</span><span class="mi">13</span><span class="p">];</span> <span class="k">enum</span><span class="w"> </span><span class="n">cardsuit</span><span class="w"> </span><span class="n">trump</span><span class="p">;</span> </pre></div> <p>C exposes the integer representation of enumeration values directly to the programmer. Integers and enum values can be mixed freely, and all arithmetic operations on enum values are permitted. It is even possible for an enum variable to hold an integer that does not represent any of the enumeration values. In fact, according to the language definition, the above code will define <code>Clubs</code>, <code>Diamonds</code>, <code>Hearts</code>, and <code>Spades</code> as constants of type <code>int</code>, which will only be converted (silently) to <code>enum cardsuit</code> if they are stored in a variable of that type. </p><p>C also allows the programmer to choose the values of the enumeration constants explicitly, even without type. For example, </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span><span class="w"> </span><span class="n">cardsuit</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Clubs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span> <span class="w"> </span><span class="n">Diamonds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span> <span class="w"> </span><span class="n">Hearts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span> <span class="w"> </span><span class="n">Spades</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">8</span> <span class="p">};</span> </pre></div> <p>could be used to define a type that allows mathematical sets of suits to be represented as an <code>enum cardsuit</code> by bitwise logic operations. </p><p>Since <a href="/wiki/C23_(C_standard_revision)" title="C23 (C standard revision)">C23</a>, the underlying type of an enumeration can be specified by the programmer:<sup id="cite_ref-N3030_2-0" class="reference"><a href="#cite_note-N3030-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span><span class="w"> </span><span class="n">cardsuit</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Clubs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span> <span class="w"> </span><span class="n">Diamonds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span> <span class="w"> </span><span class="n">Hearts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span> <span class="w"> </span><span class="n">Spades</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">8</span> <span class="p">};</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="C#"><span id="C.23"></span>C#</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=10" title="Edit section: C#" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>Enumerated types in the <a href="/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> programming language preserve most of the "small integer" semantics of C's enums. Some arithmetic operations are not defined for enums, but an enum value can be explicitly converted to an integer and back again, and an enum variable can have values that were not declared by the enum definition. For example, given </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span><span class="w"> </span><span class="n">Cardsuit</span> <span class="p">{</span> <span class="w"> </span><span class="n">Clubs</span><span class="p">,</span> <span class="w"> </span><span class="n">Diamonds</span><span class="p">,</span> <span class="w"> </span><span class="n">Spades</span><span class="p">,</span> <span class="w"> </span><span class="n">Hearts</span> <span class="p">}</span> </pre></div> <p>the expressions <code lang="csharp">CardSuit.Diamonds + 1</code> and <code lang="csharp">CardSuit.Hearts - CardSuit.Clubs</code> are allowed directly (because it may make sense to step through the sequence of values or ask how many steps there are between two values), but <code lang="csharp">CardSuit.Hearts * CardSuit.Spades</code> is deemed to make less sense and is only allowed if the values are first converted to integers. </p><p>C# also provides the C-like feature of being able to define specific integer values for enumerations. By doing this it is possible to perform binary operations on enumerations, thus treating enumeration values as sets of flags. These flags can be tested using binary operations or with the Enum type's builtin 'HasFlag' method. </p><p>The enumeration definition defines names for the selected integer values and is <a href="/wiki/Syntactic_sugar" title="Syntactic sugar">syntactic sugar</a>, as it is possible to assign to an enum variable other integer values that are not in the scope of the enum definition.<sup id="cite_ref-enum_3-0" class="reference"><a href="#cite_note-enum-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading4"><h4 id="C++"><span id="C.2B.2B"></span>C++</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=11" title="Edit section: C++" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p><a href="/wiki/C%2B%2B" title="C++">C++</a> has enumeration types that are directly inherited from C's and work mostly like these, except that an enumeration is a real type in C++, giving added compile-time checking. Also (as with structs), the C++ <code>enum</code> keyword is combined with a <style data-mw-deduplicate="TemplateStyles:r886049734">.mw-parser-output .monospaced{font-family:monospace,monospace}</style><span class="monospaced"><a href="/wiki/Typedef" title="Typedef">typedef</a></span>, so that instead of naming the type <code>enum name</code>, simply name it <code>name</code>. This can be simulated in C using a typedef: <code class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" style="" dir="ltr"><span class="k">typedef</span><span class="w"> </span><span class="k">enum</span><span class="w"> </span><span class="p">{</span><span class="n">Value1</span><span class="p">,</span><span class="w"> </span><span class="n">Value2</span><span class="p">}</span><span class="w"> </span><span class="n">name</span><span class="p">;</span></code> </p><p><a href="/wiki/C%2B%2B11" title="C++11">C++11</a> also provides a second kind of enumeration, called a <i>scoped enumeration</i>. These are type-safe: the enumerators are not implicitly converted to an integer type. Among other things, this allows I/O streaming to be defined for the enumeration type. Another feature of scoped enumerations is that the enumerators do not leak, so usage requires prefixing with the name of the enumeration (e.g., <code>Color::Red</code> for the first enumerator in the example below), unless a <code>using enum</code> declaration (introduced in <a href="/wiki/C%2B%2B20" title="C++20">C++20</a>) has been used to bring the enumerators into the current scope. A scoped enumeration is specified by the phrase <code>enum class</code> (or <code>enum struct</code>). For example: </p> <div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span><span class="w"> </span><span class="k">class</span><span class="w"> </span><span class="nc">Color</span><span class="w"> </span><span class="p">{</span><span class="n">Red</span><span class="p">,</span><span class="w"> </span><span class="n">Green</span><span class="p">,</span><span class="w"> </span><span class="n">Blue</span><span class="p">};</span> </pre></div> <p>The <i>underlying type</i> of an enumeration is an implementation-defined integral type that is large enough to hold all enumerated values; it does not have to be the smallest possible type. The underlying type can be specified directly, which allows "forward declarations" of enumerations: </p> <div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span><span class="w"> </span><span class="k">class</span><span class="w"> </span><span class="nc">Color</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="p">{</span><span class="n">Red</span><span class="p">,</span><span class="w"> </span><span class="n">Green</span><span class="p">,</span><span class="w"> </span><span class="n">Blue</span><span class="p">};</span><span class="w"> </span><span class="c1">// must fit in size and memory layout the type 'long'</span> <span class="k">enum</span><span class="w"> </span><span class="k">class</span><span class="w"> </span><span class="nc">Shapes</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="kt">char</span><span class="p">;</span><span class="w"> </span><span class="c1">// forward declaration. If later there are values defined that don't fit in 'char' it is an error.</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Go">Go</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=12" title="Edit section: Go" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p><a href="/wiki/Go_(programming_language)" title="Go (programming language)">Go</a> uses the <code>iota</code> keyword to create enumerated constants.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-go mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">type</span><span class="w"> </span><span class="nx">ByteSize</span><span class="w"> </span><span class="kt">float64</span> <span class="kd">const</span><span class="w"> </span><span class="p">(</span> <span class="w"> </span><span class="nx">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="kc">iota</span><span class="w"> </span><span class="c1">// ignore first value by assigning to blank identifier</span> <span class="w"> </span><span class="nx">KB</span><span class="w"> </span><span class="nx">ByteSize</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><<</span><span class="w"> </span><span class="p">(</span><span class="mi">10</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="kc">iota</span><span class="p">)</span> <span class="w"> </span><span class="nx">MB</span> <span class="w"> </span><span class="nx">GB</span> <span class="p">)</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Haxe">Haxe</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=13" title="Edit section: Haxe" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <div class="excerpt-block"><style data-mw-deduplicate="TemplateStyles:r1066933788">.mw-parser-output .excerpt-hat .mw-editsection-like{font-style:normal}</style><style data-mw-deduplicate="TemplateStyles:r1236090951">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}</style><div role="note" class="hatnote navigation-not-searchable dablink excerpt-hat selfref">This section is an excerpt from <a href="/wiki/Haxe#Enumerated_types" title="Haxe">Haxe § Enumerated types</a>.<span class="mw-editsection-like plainlinks"><span class="mw-editsection-bracket">[</span><a class="external text" href="https://en.wikipedia.org/w/index.php?title=Haxe&action=edit">edit</a><span class="mw-editsection-bracket">]</span></span></div><div class="excerpt"> <p>Enumerated types are an important feature of the language; they can have type parameters and be recursive.<sup id="cite_ref-Haxe_enum-reference_7-0" class="reference"><a href="#cite_note-Haxe_enum-reference-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> They provide basic support for <a href="/wiki/Algebraic_data_type" title="Algebraic data type">algebraic data types</a>, allowing the inclusion of <a href="/wiki/Product_type" title="Product type">product types</a>, in a fashion similar to <a href="/wiki/Haskell" title="Haskell">Haskell</a> and <a href="/wiki/ML_(programming_language)" title="ML (programming language)">ML</a>. A <code>switch</code> expression can apply <a href="/wiki/Pattern_matching#Tree_patterns" title="Pattern matching">pattern matching</a> to an enum value, allowing for elegant solutions to complex programming problems: </p> <div class="mw-highlight mw-highlight-lang-haxe mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">enum</span><span class="w"> </span><span class="n">Color</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">red</span><span class="p">;</span> <span class="w"> </span><span class="n">green</span><span class="p">;</span> <span class="w"> </span><span class="n">blue</span><span class="p">;</span> <span class="w"> </span><span class="n">rgb</span><span class="p">(</span><span class="n">r</span><span class="p">:</span><span class="n">Int</span><span class="p">,</span><span class="w"> </span><span class="n">g</span><span class="p">:</span><span class="n">Int</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">:</span><span class="n">Int</span><span class="p">);</span> <span class="p">}</span> <span class="kd">class</span><span class="w"> </span><span class="n">Colors</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="kd">static</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nf">toInt</span><span class="p">(</span><span class="n">c</span><span class="p">:</span><span class="n">Color</span><span class="p">):</span><span class="n">Int</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">switch</span><span class="w"> </span><span class="p">(</span><span class="n">c</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">red</span><span class="p">:</span><span class="w"> </span><span class="mh">0xFF0000</span><span class="p">;</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">green</span><span class="p">:</span><span class="w"> </span><span class="mh">0x00FF00</span><span class="p">;</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">blue</span><span class="p">:</span><span class="w"> </span><span class="mh">0x0000FF</span><span class="p">;</span> <span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">rgb</span><span class="p">(</span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="n">g</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">):</span><span class="w"> </span><span class="p">(</span><span class="n">r</span><span class="w"> </span><span class="o"><<</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">(</span><span class="n">g</span><span class="w"> </span><span class="o"><<</span><span class="w"> </span><span class="mi">8</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">b</span><span class="p">;</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="kd">static</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nf">validCalls</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="kd">var</span><span class="w"> </span>redint<span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">toInt</span><span class="p">(</span><span class="n">Color</span><span class="p">.</span><span class="n">red</span><span class="p">);</span> <span class="w"> </span><span class="kd">var</span><span class="w"> </span>rgbint<span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">toInt</span><span class="p">(</span><span class="n">Color</span><span class="p">.</span><span class="n">rgb</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">));</span> <span class="w"> </span><span class="p">}</span> <span class="p">}</span> </pre></div> <p>Examples of parametric enum types are the Haxe standard library types Option<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> and Either:<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-haxe mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">enum</span><span class="w"> </span><span class="n">Option</span><span class="p"><</span><span class="n">T</span><span class="p">></span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Some</span><span class="p">(</span><span class="n">v</span><span class="p">:</span><span class="n">T</span><span class="p">);</span> <span class="w"> </span><span class="n">None</span><span class="p">;</span> <span class="p">}</span> <span class="kd">enum</span><span class="w"> </span><span class="n">Either</span><span class="p"><</span><span class="n">L</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="p">></span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Left</span><span class="p">(</span><span class="n">v</span><span class="p">:</span><span class="n">L</span><span class="p">);</span> <span class="w"> </span><span class="n">Right</span><span class="p">(</span><span class="n">v</span><span class="p">:</span><span class="n">R</span><span class="p">);</span> <span class="p">}</span> </pre></div> Haxe also supports <a href="/wiki/Generalized_algebraic_data_type" title="Generalized algebraic data type">generalized algebraic data types</a> (GADTs).<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup></div></div> <div class="mw-heading mw-heading4"><h4 id="Java">Java</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=14" title="Edit section: Java" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <figure class="mw-default-size mw-halign-right" typeof="mw:File"><a href="/wiki/File:Cardsuit_UML_enum.svg" class="mw-file-description" title="A UML class diagram featuring a enum."><noscript><img alt="A UML class diagram featuring a enum." src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Cardsuit_UML_enum.svg/112px-Cardsuit_UML_enum.svg.png" decoding="async" width="112" height="134" class="mw-file-element" data-file-width="112" data-file-height="134"></noscript><span class="lazy-image-placeholder" style="width: 112px;height: 134px;" data-src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Cardsuit_UML_enum.svg/112px-Cardsuit_UML_enum.svg.png" data-alt="A UML class diagram featuring a enum." data-width="112" data-height="134" data-srcset="//upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Cardsuit_UML_enum.svg/168px-Cardsuit_UML_enum.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Cardsuit_UML_enum.svg/224px-Cardsuit_UML_enum.svg.png 2x" data-class="mw-file-element"> </span></a><figcaption>A UML class diagram featuring a enum.</figcaption></figure> <p>The J2SE version 5.0 of the <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java programming language</a> added enumerated types whose declaration syntax is similar to that of <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>: </p> <div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">enum</span><span class="w"> </span><span class="n">Cardsuit</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">CLUBS</span><span class="p">,</span><span class="w"> </span><span class="n">DIAMONDS</span><span class="p">,</span><span class="w"> </span><span class="n">SPADES</span><span class="p">,</span><span class="w"> </span><span class="n">HEARTS</span><span class="w"> </span><span class="p">};</span> <span class="p">...</span> <span class="n">Cardsuit</span><span class="w"> </span><span class="n">trump</span><span class="p">;</span> </pre></div> <p>The Java type system, however, treats enumerations as a type separate from integers, and intermixing of enum and integer values is not allowed. In fact, an enum type in Java is actually a special compiler-generated <a href="/wiki/Class_(computer_science)" class="mw-redirect" title="Class (computer science)">class</a> rather than an arithmetic type, and enum values behave as global pre-generated instances of that class. Enum types can have instance methods and a constructor (the arguments of which can be specified separately for each enum value). All enum types implicitly extend the <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/Enum.html">Enum</a></code> abstract class. An enum type cannot be instantiated directly.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> </p><p>Internally, each enum value contains an integer, corresponding to the order in which they are declared in the source code, starting from 0. The programmer cannot set a custom integer for an enum value directly, but one can define <a href="/wiki/Constructor_overloading" class="mw-redirect" title="Constructor overloading">overloaded constructors</a> that can then assign arbitrary values to self-defined members of the enum class. Defining getters allows then access to those self-defined members. The internal integer can be obtained from an enum value using the <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/Enum.html#ordinal()">ordinal()</a></code> method, and the list of enum values of an enumeration type can be obtained in order using the <code>values()</code> method. It is generally discouraged for programmers to convert enums to integers and vice versa.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> Enumerated types are <code>Comparable</code>, using the internal integer; as a result, they can be sorted. </p><p>The Java standard library provides utility classes to use with enumerations. The <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/EnumSet.html">EnumSet</a></code> class implements a <code>Set</code> of enum values; it is implemented as a <a href="/wiki/Bit_array" title="Bit array">bit array</a>, which makes it very compact and as efficient as explicit bit manipulation, but safer. The <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/EnumMap.html">EnumMap</a></code> class implements a <code>Map</code> of enum values to object. It is implemented as an array, with the integer value of the enum value serving as the index. </p> <div class="mw-heading mw-heading4"><h4 id="Perl">Perl</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=15" title="Edit section: Perl" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p><a href="/wiki/Dynamically_typed" class="mw-redirect" title="Dynamically typed">Dynamically typed</a> languages in the syntactic tradition of C (e.g., <a href="/wiki/Perl" title="Perl">Perl</a> or <a href="/wiki/JavaScript" title="JavaScript">JavaScript</a>) do not, in general, provide enumerations. But in Perl programming the same result can be obtained with the shorthand <a href="/wiki/String_literal" title="String literal">strings</a> <a href="/wiki/List_(abstract_data_type)" title="List (abstract data type)">list</a> and <a href="/wiki/Hash_table" title="Hash table">hashes</a> (possibly <a href="/wiki/Array_slicing" title="Array slicing">slices</a>): </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="k">my</span><span class="w"> </span><span class="nv">@enum</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="sx">qw(Clubs Diamonds Hearts Spades)</span><span class="p">;</span> <span class="k">my</span><span class="p">(</span><span class="w"> </span><span class="nv">%set1</span><span class="p">,</span><span class="w"> </span><span class="nv">%set2</span><span class="w"> </span><span class="p">);</span> <span class="nv">@set1</span><span class="p">{</span><span class="nv">@enum</span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">();</span><span class="w"> </span><span class="c1"># all cleared</span> <span class="nv">@set2</span><span class="p">{</span><span class="nv">@enum</span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="nv">@enum</span><span class="p">;</span><span class="w"> </span><span class="c1"># all set to 1</span> <span class="nv">$set1</span><span class="p">{</span><span class="n">Clubs</span><span class="p">}</span><span class="w"> </span><span class="o">...</span><span class="w"> </span><span class="c1"># false</span> <span class="nv">$set2</span><span class="p">{</span><span class="n">Diamonds</span><span class="p">}</span><span class="w"> </span><span class="o">...</span><span class="w"> </span><span class="c1"># true</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Raku">Raku</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=16" title="Edit section: Raku" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p><a href="/wiki/Raku_(programming_language)" title="Raku (programming language)">Raku</a> (formerly known as Perl 6) supports enumerations. There are multiple ways to declare enumerations in Raku, all creating a back-end Map. </p> <div class="mw-highlight mw-highlight-lang-perl6 mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span> <span class="n">Cat</span> <span class="s"><sphynx siamese bengal shorthair other></span>; <span class="c1"># Using "quote-words"</span> </pre></div> <div class="mw-highlight mw-highlight-lang-perl6 mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span> <span class="n">Cat</span> (<span class="s">'sphynx'</span>, <span class="s">'siamese'</span>, <span class="s">'bengal'</span>, <span class="s">'shorthair'</span>, <span class="s">'other'</span>); <span class="c1"># Using a list</span> </pre></div> <div class="mw-highlight mw-highlight-lang-perl6 mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span> <span class="n">Cat</span> (<span class="n">sphynx</span> => <span class="mi">0</span>, <span class="n">siamese</span> => <span class="mi">1</span>, <span class="n">bengal</span> => <span class="mi">2</span>, <span class="n">shorthair</span> => <span class="mi">3</span>, <span class="n">other</span> => <span class="mi">4</span>); <span class="c1"># Using Pair constructors</span> </pre></div> <div class="mw-highlight mw-highlight-lang-perl6 mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span> <span class="n">Cat</span> (:<span class="n">sphynx</span>(<span class="mi">0</span>), :<span class="n">siamese</span>(<span class="mi">1</span>), :<span class="n">bengal</span>(<span class="mi">2</span>), <span class="n">shorthair</span>(<span class="mi">3</span>), :<span class="n">other</span>(<span class="mi">4</span>)); <span class="c1"># Another way of using Pairs, you can also use `:0sphynx`</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="PHP">PHP</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=17" title="Edit section: PHP" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>Enums were added in PHP version 8.1. </p> <div class="mw-highlight mw-highlight-lang-php mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">enum</span> <span class="nx">CardSuit</span> <span class="p">{</span> <span class="k">case</span> <span class="nx">Hearts</span><span class="p">;</span> <span class="k">case</span> <span class="nx">Diamonds</span><span class="p">;</span> <span class="k">case</span> <span class="nx">Clubs</span><span class="p">;</span> <span class="k">case</span> <span class="nx">Spades</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p>Enumerators may be backed by string or integer values to aid serialization: </p> <div class="mw-highlight mw-highlight-lang-php mw-content-ltr" dir="ltr"><pre><span></span><span class="nx">enum</span> <span class="nx">CardSuit</span><span class="o">:</span> <span class="nx">string</span> <span class="p">{</span> <span class="k">case</span> <span class="nx">Hearts</span> <span class="o">=</span> <span class="s1">'H'</span><span class="p">;</span> <span class="k">case</span> <span class="nx">Diamonds</span> <span class="o">=</span> <span class="s1">'D'</span><span class="p">;</span> <span class="k">case</span> <span class="nx">Clubs</span> <span class="o">=</span> <span class="s1">'C'</span><span class="p">;</span> <span class="k">case</span> <span class="nx">Spades</span> <span class="o">=</span> <span class="s1">'S'</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p>The Enum's interface exposes a method that gives a collection of its enumerators and their names. String/integer-backed Enums also expose the backing value and methods to (attempt) deserialization. Users may add further methods. </p> <div class="mw-heading mw-heading4"><h4 id="Rust">Rust</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=18" title="Edit section: Rust" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>Though Rust uses the <code>enum</code> keyword like C, it uses it to describe <a href="/wiki/Tagged_union" title="Tagged union">tagged unions</a>, which enums can be considered a degenerate form of. Rust's enums are therefore much more flexible and can contain struct and tuple variants. </p> <div class="mw-highlight mw-highlight-lang-rust mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span> <span class="nc">Message</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Quit</span><span class="p">,</span> <span class="w"> </span><span class="n">Move</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="kt">i32</span> <span class="p">},</span><span class="w"> </span><span class="c1">// struct</span> <span class="w"> </span><span class="n">Write</span><span class="p">(</span><span class="nb">String</span><span class="p">),</span><span class="w"> </span><span class="c1">// single-element tuple</span> <span class="w"> </span><span class="n">ChangeColor</span><span class="p">(</span><span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="kt">i32</span><span class="p">),</span><span class="w"> </span><span class="c1">// three-element tuple</span> <span class="p">}</span> </pre></div> <p>Like C, Rust also supports specifying the values of each variant, </p> <div class="mw-highlight mw-highlight-lang-rust mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#[allow(dead_code)]</span> <span class="k">pub</span><span class="w"> </span><span class="k">enum</span> <span class="nc">Weekday</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Sunday</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span> <span class="w"> </span><span class="n">Monday</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span> <span class="w"> </span><span class="n">Tuesday</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span> <span class="w"> </span><span class="n">Wednesday</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span> <span class="w"> </span><span class="n">Thursday</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">16</span><span class="p">,</span> <span class="w"> </span><span class="n">Friday</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">32</span><span class="p">,</span> <span class="w"> </span><span class="n">Saturday</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">64</span><span class="p">,</span> <span class="p">}</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Swift">Swift</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=19" title="Edit section: Swift" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>In C, enumerations assign related names to a set of integer values. In <a href="/wiki/Swift_(programming_language)" title="Swift (programming language)">Swift</a>, enumerations are much more flexible and need not provide a value for each case of the enumeration. If a value (termed a <i>raw</i> value) is provided for each enumeration case, the value can be a string, a character, or a value of any integer or floating-point type. </p><p>Alternatively, enumeration cases can specify associated values of any type to be stored along with each different case value, much as unions or variants do in other languages. One can define a common set of related cases as part of one enumeration, each of which has a different set of values of appropriate types associated with it. </p><p>In Swift, enumerations are a first-class type. They adopt many features traditionally supported only by classes, such as computed properties to provide additional information about the enumeration's current value, and instance methods to provide functionality related to the values the enumeration represents. Enumerations can also define initializers to provide an initial case value and can be extended to expand their functionality beyond their original implementation; and can conform to protocols to provide standard functionality. </p> <div class="mw-highlight mw-highlight-lang-swift mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">enum</span> <span class="nc">CardSuit</span> <span class="p">{</span> <span class="k">case</span> <span class="n">clubs</span> <span class="k">case</span> <span class="n">diamonds</span> <span class="k">case</span> <span class="n">hearts</span> <span class="k">case</span> <span class="n">spades</span> <span class="p">}</span> </pre></div> <p>Unlike C and <a href="/wiki/Objective-C" title="Objective-C">Objective-C</a>, Swift enumeration cases are not assigned a default integer value when they are created. In the CardSuit example above, clubs, diamonds, hearts, and spades do not implicitly equal 0, 1, 2 and 3. Instead, the different enumeration cases are fully-fledged values in their own right, with an explicitly-defined type of CardSuit. </p><p>Multiple cases can appear on a single line, separated by commas: </p> <div class="mw-highlight mw-highlight-lang-swift mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">enum</span> <span class="nc">CardSuit</span> <span class="p">{</span> <span class="k">case</span> <span class="n">clubs</span><span class="p">,</span> <span class="n">diamonds</span><span class="p">,</span> <span class="n">hearts</span><span class="p">,</span> <span class="n">spades</span> <span class="p">}</span> </pre></div> <p>When working with enumerations that store integer or string raw values, one doesn't need to explicitly assign a raw value for each case because Swift will automatically assign the values. </p><p>For instance, when integers are used for raw values, the implicit value for each case is one more than the previous case. If the first case doesn't have a value set, its value is 0. For the CardSuit example, suits can be numbered starting from 1 by writing: </p> <div class="mw-highlight mw-highlight-lang-swift mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">enum</span> <span class="nc">CardSuit</span> <span class="p">{</span> <span class="k">case</span> <span class="n">clubs</span> <span class="p">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">diamonds</span><span class="p">,</span> <span class="n">hearts</span><span class="p">,</span> <span class="n">spades</span> <span class="p">}</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="TypeScript">TypeScript</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=20" title="Edit section: TypeScript" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>TypeScript adds an 'enum' data type to JavaScript. </p> <div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">enum</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="w"> </span><span class="p">{</span><span class="nx">Clubs</span><span class="p">,</span><span class="w"> </span><span class="nx">Diamonds</span><span class="p">,</span><span class="w"> </span><span class="nx">Hearts</span><span class="p">,</span><span class="w"> </span><span class="nx">Spades</span><span class="p">};</span> <span class="kd">var</span><span class="w"> </span><span class="nx">c</span><span class="o">:</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="p">.</span><span class="nx">Diamonds</span><span class="p">;</span> </pre></div> <p>By default, enums number members starting at 0; this can be overridden by setting the value of the first: </p> <div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">enum</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="w"> </span><span class="p">{</span><span class="nx">Clubs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="nx">Diamonds</span><span class="p">,</span><span class="w"> </span><span class="nx">Hearts</span><span class="p">,</span><span class="w"> </span><span class="nx">Spades</span><span class="p">};</span> <span class="kd">var</span><span class="w"> </span><span class="nx">c</span><span class="o">:</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="p">.</span><span class="nx">Diamonds</span><span class="p">;</span> </pre></div> <p>All the values can be set: </p> <div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">enum</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="w"> </span><span class="p">{</span><span class="nx">Clubs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="nx">Diamonds</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2</span><span class="p">,</span><span class="w"> </span><span class="nx">Hearts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">4</span><span class="p">,</span><span class="w"> </span><span class="nx">Spades</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">8</span><span class="p">};</span> <span class="kd">var</span><span class="w"> </span><span class="nx">c</span><span class="o">:</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="p">.</span><span class="nx">Diamonds</span><span class="p">;</span> </pre></div> <p>TypeScript supports mapping the numeric value to its name. For example, this finds the name of the value 2: </p> <div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">enum</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="w"> </span><span class="p">{</span><span class="nx">Clubs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="nx">Diamonds</span><span class="p">,</span><span class="w"> </span><span class="nx">Hearts</span><span class="p">,</span><span class="w"> </span><span class="nx">Spades</span><span class="p">};</span> <span class="kd">var</span><span class="w"> </span><span class="nx">suitName</span><span class="o">:</span><span class="w"> </span><span class="nx">string</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">Cardsuit</span><span class="p">[</span><span class="mf">2</span><span class="p">];</span> <span class="nx">alert</span><span class="p">(</span><span class="nx">suitName</span><span class="p">);</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Python">Python</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=21" title="Edit section: Python" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><p> An <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/enum.html"><code>enum</code></a> module was added to the Python standard library in version 3.4.</p><div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span> <span class="k">class</span> <span class="nc">Cards</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span> <span class="n">CLUBS</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">DIAMONDS</span> <span class="o">=</span> <span class="mi">2</span> <span class="n">HEARTS</span> <span class="o">=</span> <span class="mi">3</span> <span class="n">SPADES</span> <span class="o">=</span> <span class="mi">4</span> </pre></div> <p>There is also a <a rel="nofollow" class="external text" href="https://docs.python.org/3.4/library/enum.html#functional-api">functional API</a> for creating enumerations with automatically generated indices (starting with one): </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">Cards</span> <span class="o">=</span> <span class="n">Enum</span><span class="p">(</span><span class="s2">"Cards"</span><span class="p">,</span> <span class="s2">"CLUBS DIAMONDS HEARTS SPADES"</span><span class="p">)</span> </pre></div> <p>Python enumerations do not enforce semantic correctness (a meaningless comparison to an incompatible enumeration always returns <i>False</i> rather than raising a <i>TypeError</i>): </p> <div class="mw-highlight mw-highlight-lang-pycon mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">>>> </span><span class="n">Color</span> <span class="o">=</span> <span class="n">Enum</span><span class="p">(</span><span class="s2">"Color"</span><span class="p">,</span> <span class="s2">"RED GREEN BLUE"</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">Shape</span> <span class="o">=</span> <span class="n">Enum</span><span class="p">(</span><span class="s2">"Shape"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"CIRCLE"</span><span class="p">,</span> <span class="s2">"TRIANGLE"</span><span class="p">,</span> <span class="s2">"SQUARE"</span><span class="p">,</span> <span class="s2">"HEXAGON"</span><span class="p">])</span> <span class="gp">>>> </span><span class="k">def</span> <span class="nf">has_vertices</span><span class="p">(</span><span class="n">shape</span><span class="p">):</span> <span class="gp">... </span> <span class="k">return</span> <span class="n">shape</span> <span class="o">!=</span> <span class="n">Shape</span><span class="o">.</span><span class="n">CIRCLE</span> <span class="gp">...</span> <span class="gp">>>> </span><span class="n">has_vertices</span><span class="p">(</span><span class="n">Color</span><span class="o">.</span><span class="n">GREEN</span><span class="p">)</span> <span class="go">True</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Fortran">Fortran</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=22" title="Edit section: Fortran" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p><a href="/wiki/Fortran" title="Fortran">Fortran</a> only has enumerated types for interoperability with C; hence, the semantics is similar to C and, as in C, the enum values are just integers and no further type check is done. The C example from above can be written in Fortran as </p> <div class="mw-highlight mw-highlight-lang-fortran mw-content-ltr" dir="ltr"><pre><span></span><span class="k">enum</span><span class="p">,</span><span class="w"> </span><span class="k">bind</span><span class="p">(</span><span class="w"> </span><span class="n">C</span><span class="w"> </span><span class="p">)</span> <span class="w"> </span><span class="k">enumerator</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">CLUBS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">DIAMONDS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">HEARTS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">SPADES</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">8</span> <span class="k">end enum</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Visual_Basic/VBA"><span id="Visual_Basic.2FVBA"></span>Visual Basic/VBA</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=23" title="Edit section: Visual Basic/VBA" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p>Enumerated datatypes in <a href="/wiki/Visual_Basic" title="Visual Basic">Visual Basic</a> (up to version 6) and <a href="/wiki/Visual_Basic_for_Applications" title="Visual Basic for Applications">VBA</a> are automatically assigned the "<code>Long</code>" datatype and also become a datatype themselves: </p> <div class="mw-highlight mw-highlight-lang-vbnet mw-content-ltr" dir="ltr"><pre><span></span><span class="c">'Zero-based</span> <span class="k">Enum</span><span class="w"> </span><span class="nc">CardSuit</span> <span class="w"> </span><span class="n">Clubs</span> <span class="w"> </span><span class="n">Diamonds</span> <span class="w"> </span><span class="n">Hearts</span> <span class="w"> </span><span class="n">Spades</span> <span class="k">End</span><span class="w"> </span><span class="k">Enum</span> <span class="k">Sub</span><span class="w"> </span><span class="nf">EnumExample</span><span class="p">()</span> <span class="w"> </span><span class="k">Dim</span><span class="w"> </span><span class="n">suit</span><span class="w"> </span><span class="ow">As</span><span class="w"> </span><span class="n">CardSuit</span> <span class="w"> </span><span class="n">suit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Diamonds</span> <span class="w"> </span><span class="n">MsgBox</span><span class="w"> </span><span class="n">suit</span> <span class="k">End</span><span class="w"> </span><span class="k">Sub</span> </pre></div> <p>Example Code in <a href="/wiki/VB.NET" class="mw-redirect" title="VB.NET">VB.NET</a> </p> <div class="mw-highlight mw-highlight-lang-vbnet mw-content-ltr" dir="ltr"><pre><span></span><span class="k">Enum</span><span class="w"> </span><span class="nc">CardSuit</span> <span class="w"> </span><span class="n">Clubs</span> <span class="w"> </span><span class="n">Diamonds</span> <span class="w"> </span><span class="n">Hearts</span> <span class="w"> </span><span class="n">Spades</span> <span class="k">End</span><span class="w"> </span><span class="k">Enum</span> <span class="k">Sub</span><span class="w"> </span><span class="nf">EnumExample</span><span class="p">()</span> <span class="w"> </span><span class="k">Dim</span><span class="w"> </span><span class="n">suit</span><span class="w"> </span><span class="ow">As</span><span class="w"> </span><span class="n">CardSuit</span> <span class="w"> </span><span class="n">suit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CardSuit</span><span class="p">.</span><span class="n">Diamonds</span> <span class="w"> </span><span class="n">MessageBox</span><span class="p">.</span><span class="n">show</span><span class="p">(</span><span class="n">suit</span><span class="p">)</span> <span class="k">End</span><span class="w"> </span><span class="k">Sub</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Lisp">Lisp</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=24" title="Edit section: Lisp" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p><a href="/wiki/Common_Lisp" title="Common Lisp">Common Lisp</a> uses the member type specifier, e.g., </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">deftype</span><span class="w"> </span><span class="nv">cardsuit</span><span class="w"> </span><span class="p">()</span> <span class="w"> </span><span class="o">'</span><span class="p">(</span><span class="nb">member</span><span class="w"> </span><span class="nv">club</span><span class="w"> </span><span class="nv">diamond</span><span class="w"> </span><span class="nv">heart</span><span class="w"> </span><span class="nv">spade</span><span class="p">))</span> </pre></div> <p>that states that object is of type cardsuit if it is <code>#'eql</code> to club, diamond, heart or spade. The member type specifier is not valid as a <a href="/wiki/Common_Lisp_Object_System" title="Common Lisp Object System">Common Lisp Object System</a> (CLOS) parameter specializer, however. Instead, <code>(eql atom)</code>, which is the equivalent to <code>(member atom)</code> may be used (that is, only one member of the set may be specified with an eql type specifier, however, it may be used as a CLOS parameter specializer.) In other words, to define methods to cover an enumerated type, a method must be defined for each specific element of that type. </p><p>Additionally, </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">deftype</span><span class="w"> </span><span class="nv">finite-element-set-type</span><span class="w"> </span><span class="p">(</span><span class="k">&rest</span><span class="w"> </span><span class="nv">elements</span><span class="p">)</span> <span class="w"> </span><span class="o">`</span><span class="p">(</span><span class="nb">member</span><span class="w"> </span><span class="o">,@</span><span class="nv">elements</span><span class="p">))</span> </pre></div> <p>may be used to define arbitrary enumerated types at runtime. For instance </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nv">finite-element-set-type</span><span class="w"> </span><span class="nv">club</span><span class="w"> </span><span class="nv">diamond</span><span class="w"> </span><span class="nv">heart</span><span class="w"> </span><span class="nv">spade</span><span class="p">)</span> </pre></div> <p>would refer to a type equivalent to the prior definition of cardsuit, as of course would simply have been using </p> <div class="mw-highlight mw-highlight-lang-lisp mw-content-ltr" dir="ltr"><pre><span></span><span class="p">(</span><span class="nb">member</span><span class="w"> </span><span class="nv">club</span><span class="w"> </span><span class="nv">diamond</span><span class="w"> </span><span class="nv">heart</span><span class="w"> </span><span class="nv">spade</span><span class="p">)</span> </pre></div> <p>but may be less confusing with the function <code>#'member</code> for stylistic reasons. </p> <div class="mw-heading mw-heading4"><h4 id="Dart">Dart</h4><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=25" title="Edit section: Dart" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div> <p><a href="/wiki/Dart_(programming_language)" title="Dart (programming language)">Dart</a> has a support for the most basic form of enums and has a syntax that is a lot similar with other languages supporting enums. </p> <div class="mw-highlight mw-highlight-lang-dart mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span></span><span class="hll"><span class="linenos" data-line="1"></span><span class="n">enum</span><span class="w"> </span><span class="n">CardSuite</span><span class="w"> </span><span class="p">{</span> </span><span class="linenos" data-line="2"></span><span class="w"> </span><span class="n">Clubs</span><span class="p">,</span> <span class="linenos" data-line="3"></span><span class="w"> </span><span class="n">Diamonds</span><span class="p">,</span> <span class="linenos" data-line="4"></span><span class="w"> </span><span class="n">Hearts</span><span class="p">,</span> <span class="linenos" data-line="5"></span><span class="w"> </span><span class="n">Spades</span> <span class="linenos" data-line="6"></span><span class="p">}</span> <span class="linenos" data-line="7"></span> <span class="linenos" data-line="8"></span><span class="kt">void</span><span class="w"> </span><span class="n">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="9"></span><span class="w"> </span><span class="n">CardSuite</span><span class="w"> </span><span class="n">card</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CardSuite</span><span class="p">.</span><span class="n">Clubs</span><span class="p">;</span> <span class="linenos" data-line="10"></span> <span class="linenos" data-line="11"></span><span class="w"> </span><span class="c1">// Dart uses the "switch" operator to match the value of an enum with the desired output.</span> <span class="hll"><span class="linenos" data-line="12"></span><span class="w"> </span><span class="k">switch</span><span class="w"> </span><span class="p">(</span><span class="n">card</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> </span><span class="linenos" data-line="13"></span><span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">CardSuite</span><span class="p">.</span><span class="nl">Clubs:</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="14"></span><span class="w"> </span><span class="n">print</span><span class="p">(</span><span class="s2">"Clubs"</span><span class="p">);</span> <span class="linenos" data-line="15"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="16"></span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="linenos" data-line="17"></span> <span class="linenos" data-line="18"></span><span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">CardSuite</span><span class="p">.</span><span class="nl">Diamonds:</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="19"></span><span class="w"> </span><span class="n">print</span><span class="p">(</span><span class="s2">"Diamonds"</span><span class="p">);</span> <span class="linenos" data-line="20"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="21"></span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="linenos" data-line="22"></span> <span class="linenos" data-line="23"></span><span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">CardSuite</span><span class="p">.</span><span class="nl">Hearts:</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="24"></span><span class="w"> </span><span class="n">print</span><span class="p">(</span><span class="s2">"Hearts"</span><span class="p">);</span> <span class="linenos" data-line="25"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="26"></span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="linenos" data-line="27"></span> <span class="linenos" data-line="28"></span><span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">CardSuite</span><span class="p">.</span><span class="nl">Spades:</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="29"></span><span class="w"> </span><span class="n">print</span><span class="p">(</span><span class="s2">"Spades"</span><span class="p">);</span> <span class="linenos" data-line="30"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="31"></span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="linenos" data-line="32"></span> <span class="linenos" data-line="33"></span><span class="w"> </span><span class="k">default</span><span class="o">:</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="34"></span><span class="w"> </span><span class="n">print</span><span class="p">(</span><span class="s2">"Unknown"</span><span class="p">);</span> <span class="linenos" data-line="35"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="36"></span><span class="w"> </span><span class="k">break</span><span class="p">;</span> <span class="linenos" data-line="37"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="38"></span><span class="p">}</span> </pre></div> <p>Note that the switch operator does not guarantee the completeness of the cases. This means if you omit one case, the compiler will not raise an error. </p> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(5)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="Algebraic_data_type_in_functional_programming">Algebraic data type in functional programming</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=26" title="Edit section: Algebraic data type in functional programming" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-5 collapsible-block" id="mf-section-5"> <p>In <a href="/wiki/Functional_programming" title="Functional programming">functional programming</a> languages in the <a href="/wiki/ML_(programming_language)" title="ML (programming language)">ML</a> lineage (e.g., <a href="/wiki/Standard_ML" title="Standard ML">Standard ML</a> (SML), <a href="/wiki/OCaml" title="OCaml">OCaml</a>, and <a href="/wiki/Haskell_(programming_language)" class="mw-redirect" title="Haskell (programming language)">Haskell</a>), an <a href="/wiki/Algebraic_data_type" title="Algebraic data type">algebraic data type</a> with only <a href="/wiki/Nullary_constructor" title="Nullary constructor">nullary constructors</a> can be used to implement an enumerated type. For example (in the syntax of SML signatures): </p> <div class="mw-highlight mw-highlight-lang-sml mw-content-ltr" dir="ltr"><pre><span></span><span class="kr">datatype</span> <span class="kt">cardsuit</span> <span class="p">=</span> <span class="nc">Clubs</span> <span class="p">|</span> <span class="nc">Diamonds</span> <span class="p">|</span> <span class="nc">Hearts</span> <span class="p">|</span> <span class="nc">Spades</span> <span class="kr">type</span> <span class="kt">card</span> <span class="p">=</span> <span class="p">{</span> <span class="n">suit</span><span class="p">:</span> <span class="n">cardsuit</span><span class="p">;</span> <span class="n">value</span><span class="p">:</span> <span class="n">int</span> <span class="p">}</span> <span class="kr">val</span> <span class="nv">hand</span> <span class="p">:</span> <span class="n">card</span> <span class="n">list</span> <span class="kr">val</span> <span class="nv">trump</span> <span class="p">:</span> <span class="n">cardsuit</span> </pre></div> <p>In these languages the small-integer representation is completely hidden from the programmer, if indeed such a representation is employed by the implementation. However, Haskell has the <code>Enum</code> <a href="/wiki/Type_class" title="Type class">type class</a> which a type can derive or implement to get a mapping between the type and <code>Int</code>. </p> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(6)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="Databases">Databases</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=27" title="Edit section: Databases" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-6 collapsible-block" id="mf-section-6"> <p>Some <a href="/wiki/Database" title="Database">databases</a> support enumerated types directly. <a href="/wiki/MySQL" title="MySQL">MySQL</a> provides an enumerated type <code>ENUM</code> with allowable values specified as strings when a table is created. The values are stored as numeric indices with the empty string stored as 0, the first string value stored as 1, the second string value stored as 2, etc. Values can be stored and retrieved as numeric indexes or string values.<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> </p><p>Example: </p> <div class="mw-highlight mw-highlight-lang-mysql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">shirts</span><span class="w"> </span><span class="p">(</span> <span class="w"> </span><span class="k">name</span><span class="w"> </span><span class="kt">VARCHAR</span><span class="p">(</span><span class="mi">40</span><span class="p">),</span> <span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="kt">ENUM</span><span class="p">(</span><span class="s1">'x-small'</span><span class="p">,</span><span class="w"> </span><span class="s1">'small'</span><span class="p">,</span><span class="w"> </span><span class="s1">'medium'</span><span class="p">,</span><span class="w"> </span><span class="s1">'large'</span><span class="p">,</span><span class="w"> </span><span class="s1">'x-large'</span><span class="p">)</span> <span class="p">);</span> </pre></div> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(7)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="XML_Schema">XML Schema</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=28" title="Edit section: XML Schema" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-7 collapsible-block" id="mf-section-7"> <p><a href="/wiki/XML_Schema_(W3C)" title="XML Schema (W3C)">XML Schema</a> supports enumerated types through the enumeration facet used for constraining most primitive datatypes such as strings. </p> <div class="mw-highlight mw-highlight-lang-xml mw-content-ltr" dir="ltr"><pre><span></span><span class="nt"><xs:element</span><span class="w"> </span><span class="na">name=</span><span class="s">"cardsuit"</span><span class="nt">></span> <span class="w"> </span><span class="nt"><xs:simpleType></span> <span class="w"> </span><span class="nt"><xs:restriction</span><span class="w"> </span><span class="na">base=</span><span class="s">"xs:string"</span><span class="nt">></span> <span class="w"> </span><span class="nt"><xs:enumeration</span><span class="w"> </span><span class="na">value=</span><span class="s">"Clubs"</span><span class="nt">/></span> <span class="w"> </span><span class="nt"><xs:enumeration</span><span class="w"> </span><span class="na">value=</span><span class="s">"Diamonds"</span><span class="nt">/></span> <span class="w"> </span><span class="nt"><xs:enumeration</span><span class="w"> </span><span class="na">value=</span><span class="s">"Hearts"</span><span class="nt">/></span> <span class="w"> </span><span class="nt"><xs:enumeration</span><span class="w"> </span><span class="na">value=</span><span class="s">"Spades"</span><span class="nt">/></span> <span class="w"> </span><span class="nt"></xs:restriction></span> <span class="w"> </span><span class="nt"></xs:simpleType></span> <span class="nt"></xs:element></span> </pre></div> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(8)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="See_also">See also</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=29" title="Edit section: See also" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-8 collapsible-block" id="mf-section-8"> <ul><li><a href="/wiki/Contrast_set" title="Contrast set">Contrast set</a></li></ul> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(9)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="References">References</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=30" title="Edit section: References" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-9 collapsible-block" id="mf-section-9"> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist reflist-columns references-column-width reflist-columns-2"> <ol class="references"> <li id="cite_note-k&r1e-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-k&r1e_1-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite id="CITEREFKernighanRitchie1978" class="citation book cs1"><a href="/wiki/Brian_Kernighan" title="Brian Kernighan">Kernighan, Brian W.</a>; <a href="/wiki/Dennis_Ritchie" title="Dennis Ritchie">Ritchie, Dennis M.</a> (February 1978). <a rel="nofollow" class="external text" href="https://archive.org/details/cprogramminglang00kern"><i>The C Programming Language</i></a> (1st ed.). <a href="/wiki/Englewood_Cliffs,_NJ" class="mw-redirect" title="Englewood Cliffs, NJ">Englewood Cliffs, NJ</a>: <a href="/wiki/Prentice_Hall" title="Prentice Hall">Prentice Hall</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-13-110163-3" title="Special:BookSources/0-13-110163-3"><bdi>0-13-110163-3</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=The+C+Programming+Language&rft.place=Englewood+Cliffs%2C+NJ&rft.edition=1st&rft.pub=Prentice+Hall&rft.date=1978-02&rft.isbn=0-13-110163-3&rft.aulast=Kernighan&rft.aufirst=Brian+W.&rft.au=Ritchie%2C+Dennis+M.&rft_id=https%3A%2F%2Farchive.org%2Fdetails%2Fcprogramminglang00kern&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-N3030-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-N3030_2-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://open-std.org/JTC1/SC22/WG14/www/docs/n3030.htm">"WG14-N3030 : Enhancements to Enumerations"</a>. 2022-07-19.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=WG14-N3030+%3A+Enhancements+to+Enumerations&rft.date=2022-07-19&rft_id=https%3A%2F%2Fopen-std.org%2FJTC1%2FSC22%2FWG14%2Fwww%2Fdocs%2Fn3030.htm&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-enum-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-enum_3-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFObasanjo2007" class="citation web cs1">Obasanjo, Dare (2007). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120910061600/http://25hoursaday.com/">"A Comparison of Microsoft's C# Programming Language to Sun Microsystems' Java Programming Language"</a>. Archived from the original on 2012-09-10<span class="reference-accessdate">. Retrieved <span class="nowrap">2012-09-06</span></span>. <q>In Java, enumerated types are a full fledged class which means they are typesafe and can be extended by adding methods, fields or even implementing interfaces. Whereas in C#, an enumerated type is simply syntactic sugar around an integral type (typically an int) meaning they cannot be extended and are not typesafe.</q></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=A+Comparison+of+Microsoft%27s+C%23+Programming+Language+to+Sun+Microsystems%27+Java+Programming+Language&rft.date=2007&rft.aulast=Obasanjo&rft.aufirst=Dare&rft_id=http%3A%2F%2Fwww.25hoursaday.com%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span><span class="cs1-maint citation-comment"><code class="cs1-code">{{<a href="/wiki/Template:Cite_web" title="Template:Cite web">cite web</a>}}</code>: CS1 maint: bot: original URL status unknown (<a href="/wiki/Category:CS1_maint:_bot:_original_URL_status_unknown" title="Category:CS1 maint: bot: original URL status unknown">link</a>)</span></span> </li> <li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFGruntz2005" class="citation web cs1 cs1-prop-foreign-lang-source">Gruntz, Dominik, Prof. Dr. (2005-04-08). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20070107062227/http://www.cstruter.com/">"Java 5: Taming the Tiger: Syntactic Sugar"</a> (in German). Fachhochschule Aargau, Nordwestschweiz. Archived from <a rel="nofollow" class="external text" href="http://www.cstruter.com/">the original</a> on 2007-01-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2012-09-10</span></span>. <q>Enumerationen sind die heimlichen Sieger von Java 1.5. Nach vielen Beteuerungen durch Sun, Enums seien in Java überflüssig und können einfach nachgebildet werden, wurden sie nun doch eingeführt. Die einfachste Möglichkeit einer Enumeration der Jahreszeiten sieht wie folgt aus … Das Schlüsselwort enum steht für eine spezielle Art von Klasse, die eine Enumeration definiert. … <i>Im Gegensatz zu anderen Programmiersprachen wie C/C++ und C# kann man ihnen per Gleichheitszeichen keine ganzen Zahlen zuordnen.</i></q></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Java+5%3A+Taming+the+Tiger%3A+Syntactic+Sugar&rft.pub=Fachhochschule+Aargau%2C+Nordwestschweiz&rft.date=2005-04-08&rft.aulast=Gruntz&rft.aufirst=Dominik%2C+Prof.+Dr.&rft_id=http%3A%2F%2Fwww.cstruter.com%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span><span class="cs1-maint citation-comment"><code class="cs1-code">{{<a href="/wiki/Template:Cite_web" title="Template:Cite web">cite web</a>}}</code>: CS1 maint: multiple names: authors list (<a href="/wiki/Category:CS1_maint:_multiple_names:_authors_list" title="Category:CS1 maint: multiple names: authors list">link</a>)</span> <a rel="nofollow" class="external text" href="http://www.gruntz.ch/courses/sem/ss05/Java5_SyntacticSugar.pdf">Alt URL</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20130527074954/http://www.gruntz.ch/courses/sem/ss05/Java5_SyntacticSugar.pdf">Archived</a> 2013-05-27 at the <a href="/wiki/Wayback_Machine" title="Wayback Machine">Wayback Machine</a></span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFTruter2011" class="citation web cs1">Truter, Christoff (2011-08-04). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20070107062227/http://www.cstruter.com/">"Syntactic sugar (C#): Enum"</a>. CSTrüter. Archived from the original on 2007-01-07<span class="reference-accessdate">. Retrieved <span class="nowrap">2012-09-10</span></span>. <q>// Poorly designed enum don't do this … Obviously (like with everything else), we can misuse this piece of sugar ending up with a system suffering from hyperglycemia. … Seeing as the underlying type of our enum is an int (can also use other integral types) it can lead to some interesting issues when using an enum as bit flags via bitwise operators.</q></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Syntactic+sugar+%28C%23%29%3A+Enum&rft.pub=CSTr%C3%BCter&rft.date=2011-08-04&rft.aulast=Truter&rft.aufirst=Christoff&rft_id=http%3A%2F%2Fwww.cstruter.com%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span><span class="cs1-maint citation-comment"><code class="cs1-code">{{<a href="/wiki/Template:Cite_web" title="Template:Cite web">cite web</a>}}</code>: CS1 maint: bot: original URL status unknown (<a href="/wiki/Category:CS1_maint:_bot:_original_URL_status_unknown" title="Category:CS1 maint: bot: original URL status unknown">link</a>)</span></span> </li> <li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://golang.org/doc/effective_go.html#constants">"Effective Go"</a>. <i>golang.org</i>. The Go Authors<span class="reference-accessdate">. Retrieved <span class="nowrap">2014-05-13</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=golang.org&rft.atitle=Effective+Go&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Feffective_go.html%23constants&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-Haxe_enum-reference-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-Haxe_enum-reference_7-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20120511193500/http://haxe.org/ref/enums">"Haxe reference detailing the use of enum"</a>. Archived from <a rel="nofollow" class="external text" href="http://haxe.org/ref/enums">the original</a> on 2012-05-11.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Haxe+reference+detailing+the+use+of+enum&rft_id=http%3A%2F%2Fhaxe.org%2Fref%2Fenums&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/ds/Option.hx">"haxe/Option.hx at development · HaxeFoundation/haxe"</a>. <i>Github</i>. 7 November 2021.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Github&rft.atitle=haxe%2FOption.hx+at+development+%C2%B7+HaxeFoundation%2Fhaxe&rft.date=2021-11-07&rft_id=https%3A%2F%2Fgithub.com%2FHaxeFoundation%2Fhaxe%2Fblob%2Fdevelopment%2Fstd%2Fhaxe%2Fds%2FOption.hx&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/ds/Either.hx">"haxe/Either.hx at development · HaxeFoundation/haxe"</a>. <i>Github</i>. 7 November 2021.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Github&rft.atitle=haxe%2FEither.hx+at+development+%C2%B7+HaxeFoundation%2Fhaxe&rft.date=2021-11-07&rft_id=https%3A%2F%2Fgithub.com%2FHaxeFoundation%2Fhaxe%2Fblob%2Fdevelopment%2Fstd%2Fhaxe%2Fds%2FEither.hx&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://haxe.org/documentation/introduction/language-features.html">"Language Features"</a>. <i>Haxe - The Cross-platform Toolkit</i>. Haxe Foundation<span class="reference-accessdate">. Retrieved <span class="nowrap">30 April</span> 2015</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Haxe+-+The+Cross-platform+Toolkit&rft.atitle=Language+Features&rft_id=http%3A%2F%2Fhaxe.org%2Fdocumentation%2Fintroduction%2Flanguage-features.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/HaxeFoundation/haxe/blob/development/tests/unit/src/unit/TestGADT.hx">"haxe/TestGADT.hx at development · HaxeFoundation/haxe"</a>. <i>Github</i>. 7 November 2021.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Github&rft.atitle=haxe%2FTestGADT.hx+at+development+%C2%B7+HaxeFoundation%2Fhaxe&rft.date=2021-11-07&rft_id=https%3A%2F%2Fgithub.com%2FHaxeFoundation%2Fhaxe%2Fblob%2Fdevelopment%2Ftests%2Funit%2Fsrc%2Funit%2FTestGADT.hx&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html">"Enum Types"</a>. Oracle<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-12-05</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Enum+Types&rft.pub=Oracle&rft_id=http%3A%2F%2Fdocs.oracle.com%2Fjavase%2Ftutorial%2Fjava%2FjavaOO%2Fenum.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFBloch2008" class="citation book cs1"><a href="/wiki/Joshua_Bloch" title="Joshua Bloch">Bloch, Joshua</a> (2008). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/effectivejava00bloc_0/page/158"><i>Effective Java</i></a></span> (Second ed.). Upper Saddle River, N.J.: Addison-Wesley. p. <a rel="nofollow" class="external text" href="https://archive.org/details/effectivejava00bloc_0/page/158">158</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-0-321-35668-0" title="Special:BookSources/978-0-321-35668-0"><bdi>978-0-321-35668-0</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Effective+Java&rft.place=Upper+Saddle+River%2C+N.J.&rft.pages=158&rft.edition=Second&rft.pub=Addison-Wesley&rft.date=2008&rft.isbn=978-0-321-35668-0&rft.aulast=Bloch&rft.aufirst=Joshua&rft_id=https%3A%2F%2Farchive.org%2Fdetails%2Feffectivejava00bloc_0%2Fpage%2F158&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> <li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://dev.mysql.com/doc/refman/8.0/en/enum.html">"MySQL :: MySQL 8.0 Reference Manual :: 11.3.5 The ENUM Type"</a>. <i>dev.mysql.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">19 September</span> 2021</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=dev.mysql.com&rft.atitle=MySQL+%3A%3A+MySQL+8.0+Reference+Manual+%3A%3A+11.3.5+The+ENUM+Type&rft_id=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F8.0%2Fen%2Fenum.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AEnumerated+type" class="Z3988"></span></span> </li> </ol></div> </section><div class="mw-heading mw-heading2 section-heading" onclick="mfTempOpenSection(10)"><span class="indicator mf-icon mf-icon-expand mf-icon--small"></span><h2 id="External_links">External links</h2><span class="mw-editsection"> <a role="button" href="/w/index.php?title=Enumerated_type&action=edit&section=31" title="Edit section: External links" class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet "> <span class="minerva-icon minerva-icon--edit"></span> <span>edit</span> </a> </span> </div><section class="mf-section-10 collapsible-block" id="mf-section-10"> <style data-mw-deduplicate="TemplateStyles:r1235681985">.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}</style><style data-mw-deduplicate="TemplateStyles:r1237033735">@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}</style><div class="side-box side-box-right plainlinks sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}</style> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><span><noscript><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png" decoding="async" width="40" height="40" class="mw-file-element" data-file-width="400" data-file-height="400"></noscript><span class="lazy-image-placeholder" style="width: 40px;height: 40px;" data-src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png" data-alt="" data-width="40" data-height="40" data-srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/60px-Wikibooks-logo-en-noslogan.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/80px-Wikibooks-logo-en-noslogan.svg.png 2x" data-class="mw-file-element"> </span></span></span></div> <div class="side-box-text plainlist">The Wikibook <i><a href="https://en.wikibooks.org/wiki/Ada_Programming" class="extiw" title="wikibooks:Ada Programming">Ada Programming</a></i> has a page on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Ada_Programming/Types/Enumeration" class="extiw" title="wikibooks:Ada Programming/Types/Enumeration">Enumeration</a></b></i></div></div> </div> <ul><li><a rel="nofollow" class="external text" href="http://www.cppreference.com/keywords/enum.html">Enumerated types in C/C++</a></li> <li><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/cc138362.aspx">Enumerated types in C#</a></li> <li><a rel="nofollow" class="external text" href="http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html">Enumerated types in Java</a></li> <li><a rel="nofollow" class="external text" href="http://dev.mysql.com/doc/refman/5.1/en/enum.html">Enumerated types in MySQL</a></li> <li><a rel="nofollow" class="external text" href="https://archive.today/20130201203915/http://www.rps-obix.com/docs/manuals/enumerated_data_type.html">Enumerated types in Obix</a></li> <li><a rel="nofollow" class="external text" href="https://www.php.net/manual/en/language.enumerations.overview.php">Enumerated types in PHP</a></li> <li><a rel="nofollow" class="external text" href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html">Enumerated types in Swift</a></li> <li><a rel="nofollow" class="external text" href="http://www.w3.org/TR/xmlschema-2/">Enumerated types in XML</a></li> <li><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/93khb7k9.aspx">Enumerated types in Visual Basic</a></li></ul> <div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}</style><style data-mw-deduplicate="TemplateStyles:r1236075235">.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}</style></div> <!-- NewPP limit report Parsed by mw‐api‐int.codfw.main‐849f99967d‐wll9x Cached time: 20241123070740 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.545 seconds Real time usage: 0.684 seconds Preprocessor visited node count: 1624/1000000 Post‐expand include size: 48723/2097152 bytes Template argument size: 1139/2097152 bytes Highest expansion depth: 13/100 Expensive parser function count: 52/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 113107/5000000 bytes Lua time usage: 0.346/10.000 seconds Lua memory usage: 5923610/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 536.775 1 -total 36.43% 195.521 1 Template:Reflist 17.61% 94.511 1 Template:Data_types 17.32% 92.945 2 Template:Cite_book 17.26% 92.657 1 Template:Navbox 16.65% 89.400 1 Template:Short_description 16.06% 86.207 1 Template:Excerpt 12.25% 65.760 12 Template:Cite_web 10.89% 58.429 2 Template:Pagetype 5.00% 26.813 1 Template:Wikibooks --> <!-- Saved in parser cache with key enwiki:pcache:idhash:4723370-0!canonical and timestamp 20241123070740 and revision id 1258670035. Rendering was triggered because: api-parse --> </section></div> <!-- MobileFormatter took 0.037 seconds --><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.m.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1&mobile=1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Enumerated_type&oldid=1258670035">https://en.wikipedia.org/w/index.php?title=Enumerated_type&oldid=1258670035</a>"</div></div> </div> <div class="post-content" id="page-secondary-actions"> </div> </main> <footer class="mw-footer minerva-footer" role="contentinfo"> <a class="last-modified-bar" href="/w/index.php?title=Enumerated_type&action=history"> <div class="post-content last-modified-bar__content"> <span class="minerva-icon minerva-icon-size-medium minerva-icon--modified-history"></span> <span class="last-modified-bar__text modified-enhancement" data-user-name="97.120.205.188" data-user-gender="unknown" data-timestamp="1732143821"> <span>Last edited on 20 November 2024, at 23:03</span> </span> <span class="minerva-icon minerva-icon-size-small minerva-icon--expand"></span> </div> </a> <div class="post-content footer-content"> <div id='mw-data-after-content'> <div class="read-more-container"></div> </div> <div id="p-lang"> <h4>Languages</h4> <section> <ul id="p-variants" class="minerva-languages"></ul> <ul class="minerva-languages"><li class="interlanguage-link interwiki-cs mw-list-item"><a href="https://cs.wikipedia.org/wiki/V%C3%BD%C4%8Dtov%C3%BD_typ" title="Výčtový typ – Czech" lang="cs" hreflang="cs" data-title="Výčtový typ" data-language-autonym="Čeština" data-language-local-name="Czech" class="interlanguage-link-target"><span>Čeština</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Aufz%C3%A4hlungstyp" title="Aufzählungstyp – German" lang="de" hreflang="de" data-title="Aufzählungstyp" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Type_%C3%A9num%C3%A9r%C3%A9" title="Type énuméré – French" lang="fr" hreflang="fr" data-title="Type énuméré" data-language-autonym="Français" data-language-local-name="French" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%EC%97%B4%EA%B1%B0%ED%98%95" title="열거형 – Korean" lang="ko" hreflang="ko" data-title="열거형" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-is mw-list-item"><a href="https://is.wikipedia.org/wiki/Upptalningartag" title="Upptalningartag – Icelandic" lang="is" hreflang="is" data-title="Upptalningartag" data-language-autonym="Íslenska" data-language-local-name="Icelandic" class="interlanguage-link-target"><span>Íslenska</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Enumeratie_(datatype)" title="Enumeratie (datatype) – Dutch" lang="nl" hreflang="nl" data-title="Enumeratie (datatype)" data-language-autonym="Nederlands" data-language-local-name="Dutch" class="interlanguage-link-target"><span>Nederlands</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/%E5%88%97%E6%8C%99%E5%9E%8B" title="列挙型 – Japanese" lang="ja" hreflang="ja" data-title="列挙型" data-language-autonym="日本語" data-language-local-name="Japanese" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-no mw-list-item"><a href="https://no.wikipedia.org/wiki/Oppregningstype" title="Oppregningstype – Norwegian Bokmål" lang="nb" hreflang="nb" data-title="Oppregningstype" data-language-autonym="Norsk bokmål" data-language-local-name="Norwegian Bokmål" class="interlanguage-link-target"><span>Norsk bokmål</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Wyliczeniowy_typ_danych" title="Wyliczeniowy typ danych – Polish" lang="pl" hreflang="pl" data-title="Wyliczeniowy typ danych" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Enumera%C3%A7%C3%A3o_(tipo_de_dado)" title="Enumeração (tipo de dado) – Portuguese" lang="pt" hreflang="pt" data-title="Enumeração (tipo de dado)" data-language-autonym="Português" data-language-local-name="Portuguese" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/%D0%9F%D0%B5%D1%80%D0%B5%D1%87%D0%B8%D1%81%D0%BB%D1%8F%D0%B5%D0%BC%D1%8B%D0%B9_%D1%82%D0%B8%D0%BF" title="Перечисляемый тип – Russian" lang="ru" hreflang="ru" data-title="Перечисляемый тип" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-sv mw-list-item"><a href="https://sv.wikipedia.org/wiki/Uppr%C3%A4kningstyp" title="Uppräkningstyp – Swedish" lang="sv" hreflang="sv" data-title="Uppräkningstyp" data-language-autonym="Svenska" data-language-local-name="Swedish" class="interlanguage-link-target"><span>Svenska</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%9F%D0%B5%D1%80%D0%B5%D0%BB%D1%96%D1%87%D1%83%D0%B2%D0%B0%D0%BD%D0%B8%D0%B9_%D1%82%D0%B8%D0%BF_%D0%B4%D0%B0%D0%BD%D0%B8%D1%85" title="Перелічуваний тип даних – Ukrainian" lang="uk" hreflang="uk" data-title="Перелічуваний тип даних" data-language-autonym="Українська" data-language-local-name="Ukrainian" class="interlanguage-link-target"><span>Українська</span></a></li><li class="interlanguage-link interwiki-zh-yue mw-list-item"><a href="https://zh-yue.wikipedia.org/wiki/%E5%88%97%E8%88%89" title="列舉 – Cantonese" lang="yue" hreflang="yue" data-title="列舉" data-language-autonym="粵語" data-language-local-name="Cantonese" class="interlanguage-link-target"><span>粵語</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/%E6%9E%9A%E4%B8%BE" title="枚举 – Chinese" lang="zh" hreflang="zh" data-title="枚举" data-language-autonym="中文" data-language-local-name="Chinese" class="interlanguage-link-target"><span>中文</span></a></li></ul> </section> </div> <div class="minerva-footer-logo"><img src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" alt="Wikipedia" width="120" height="18" style="width: 7.5em; height: 1.125em;"/> </div> <ul id="footer-info" class="footer-info hlist hlist-separated"> <li id="footer-info-lastmod"> This page was last edited on 20 November 2024, at 23:03<span class="anonymous-show"> (UTC)</span>.</li> <li id="footer-info-copyright">Content is available under <a class="external" rel="nofollow" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">CC BY-SA 4.0</a> unless otherwise noted.</li> </ul> <ul id="footer-places" class="footer-places hlist hlist-separated"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-terms-use"><a href="https://foundation.m.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use">Terms of Use</a></li> <li id="footer-places-desktop-toggle"><a id="mw-mf-display-toggle" href="//en.wikipedia.org/w/index.php?title=Enumerated_type&mobileaction=toggle_view_desktop" data-event-name="switch_to_desktop">Desktop</a></li> </ul> </div> </footer> </div> </div> <div class="mw-notification-area" data-mw="interface"></div> <!-- v:8.3.1 --> <script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-f69cdc8f6-rf9q5","wgBackendResponseTime":225,"wgPageParseReport":{"limitreport":{"cputime":"0.545","walltime":"0.684","ppvisitednodes":{"value":1624,"limit":1000000},"postexpandincludesize":{"value":48723,"limit":2097152},"templateargumentsize":{"value":1139,"limit":2097152},"expansiondepth":{"value":13,"limit":100},"expensivefunctioncount":{"value":52,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":113107,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 536.775 1 -total"," 36.43% 195.521 1 Template:Reflist"," 17.61% 94.511 1 Template:Data_types"," 17.32% 92.945 2 Template:Cite_book"," 17.26% 92.657 1 Template:Navbox"," 16.65% 89.400 1 Template:Short_description"," 16.06% 86.207 1 Template:Excerpt"," 12.25% 65.760 12 Template:Cite_web"," 10.89% 58.429 2 Template:Pagetype"," 5.00% 26.813 1 Template:Wikibooks"]},"scribunto":{"limitreport-timeusage":{"value":"0.346","limit":"10.000"},"limitreport-memusage":{"value":5923610,"limit":52428800}},"cachereport":{"origin":"mw-api-int.codfw.main-849f99967d-wll9x","timestamp":"20241123070740","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Enumerated type","url":"https:\/\/en.wikipedia.org\/wiki\/Enumerated_type","sameAs":"http:\/\/www.wikidata.org\/entity\/Q760170","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q760170","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2006-04-12T19:24:01Z","dateModified":"2024-11-20T23:03:41Z","headline":"data type consisting of an unordered set of named values"}</script><script>(window.NORLQ=window.NORLQ||[]).push(function(){var ns,i,p,img;ns=document.getElementsByTagName('noscript');for(i=0;i<ns.length;i++){p=ns[i].nextSibling;if(p&&p.className&&p.className.indexOf('lazy-image-placeholder')>-1){img=document.createElement('img');img.setAttribute('src',p.getAttribute('data-src'));img.setAttribute('width',p.getAttribute('data-width'));img.setAttribute('height',p.getAttribute('data-height'));img.setAttribute('alt',p.getAttribute('data-alt'));p.parentNode.replaceChild(img,p);}}});</script> </body> </html>