liveBook · Manning

Enum

Also called enumeration

An enum is a type whose values are selected from a finite set of named alternatives.

How 25 Manning books explain it

Learn Go with Pocket-Sized Projects

An enumeration is a finite set of named values representing alternatives of the same conceptual kind.

How it is used
Uses enums to represent logging levels and character feedback in a word game.
How deep it goes
Explains declarations, zero-value ordering, and string representation, including a default case for unexpected values.
Examples
Demonstrates three logging levels and three word-game character statuses.
What you can do after
Apply enums in Go using named integer-based types and iota.

Read how Learn Go with Pocket-Sized Projects explains enum →

Secure APIs

An enumeration is a type whose permitted values are restricted to a finite, explicitly defined set of named alternatives.

How it is used
Restricts API parameters and data received from external or internal services to values the application explicitly supports.
How deep it goes
Defines named alternatives and demonstrates validation and attack prevention, but does not detail enumeration internals.
Examples
Uses character statuses, product sorting fields, and printed-versus-ebook formats as concrete constrained-value examples.
What you can do after
Apply it via OpenAPI schemas or Pydantic models to reject unsupported values before processing or persistence.

Read how Secure APIs explains enum →

Python How-To

Enumeration is the technique of associating each item in a set of related concepts with a distinct named member of a common category.

How it is used
Groups fixed, related choices into a type that makes expected inputs clearer.
How deep it goes
Demonstrates member definition, lookup, iteration and custom methods, and contrasts enums with regular class attributes.
Examples
Uses compass directions, task statuses and database options to illustrate named choices.
What you can do after
Apply it via Python’s enum module to define, inspect and customize named choices.

Read how Python How-To explains enum →

Refactoring to Rust

An enum is a type whose value is exactly one of a fixed set of named variants, with each variant optionally carrying associated data.

How it is used
Uses enums to communicate typed outcomes between functions and represent possible failures.
How deep it goes
Works through variant declaration, associated data, matching, custom errors, and error propagation.
Examples
Refactors FizzBuzz from string results to variants carrying numbers, then adds a negative-input error.
What you can do after
Build enums from scratch and use them with match and Result to handle function outcomes and errors.

Read how Refactoring to Rust explains enum →

100 Java Mistakes and How to Avoid Them

An enum type is a Java class-like type that defines a fixed set of named constants.

How it is used
Models fixed named states and replaces ambiguous null results with explicit outcomes.
How deep it goes
Explains initialization ordering, constructor cycles, values() failure, and pre-Java-21 switch desugaring.
Examples
Uses mutually referencing Pet and Voice constants, a DayOfWeek weekend field, user answers, and RoundingMode.UNNECESSARY.
What you can do after
Diagnose/debug enum initialization nulls and model distinct absent-result meanings as named constants.

Read how 100 Java Mistakes and How to Avoid Them explains enum →

Rust in Action: Systems programming concepts and techniques

An enum is a type whose value is one of a finite set of named variants, optionally carrying associated data.

How it is used
Uses enums to represent known choices, internal state, and distinct upstream errors in Rust programs.
How deep it goes
Explains definitions, data-carrying variants, pattern matching, state changes, and error conversion through worked code.
Examples
Illustrates card suits, event logs, mock file states, network transitions, wrapped errors, and VGA colors.
What you can do after
Build enum types from scratch to model choices and state, and wrap upstream errors with conversions.

Read how Rust in Action: Systems programming concepts and techniques explains enum →

Learn Rust in a Month of Lunches

An enum is a Rust user-defined type whose values are one of a fixed set of named variants, optionally carrying associated data.

How it is used
Uses enums to model one choice and carry different data types within a single collection.
How deep it goes
Explains declarations, data-carrying variants, matching, integer casts, imports, and methods through worked examples.
Examples
Uses sky conditions with descriptions, a vector of signed and unsigned numbers, and a mood-checking method.
What you can do after
Build enums from scratch, select and match variants, store different data types, and add methods.

Read how Learn Rust in a Month of Lunches explains enum →

Essential TypeScript 5, Third Edition

An enum value is a named value belonging to an enum.

How it is used
Names related values for consistent use in product processing and interactive application commands.
How deep it goes
Explains declaration, numeric and string values, generated JavaScript, const enums, and value-checking limitations.
Examples
Demonstrates product prices in tuples and command selection in a to-do application using Inquirer.js.
What you can do after
Build it from scratch with named numeric or string members, then use those members in application decisions.

Read how Essential TypeScript 5, Third Edition explains enum →

Software Design for Python Programmers

An enumeration type defines a fixed set of named constant values.

How it is used
Constrains book genres to a fixed set while reducing typo and comparison risks in catalogue searches.
How deep it goes
Defines enumeration constants and contrasts them with strings, but does not explore enumeration internals.
Examples
Uses book genres such as ADVENTURE and CLASSICS in Python catalogue construction and search examples.
What you can do after
Apply it via Python's Enum class to represent a bounded attribute safely.

Read how Software Design for Python Programmers explains enum →

Functional Programming in Scala, Second Edition

An enumeration is a type declaration that defines a finite set of named data constructors.

How it is used
Defines algebraic data types by enumerating their permitted data constructors.
How deep it goes
Explains constructors, type parameters, recursive cases, pattern matching, and sealed-trait alternatives, but defers incidental syntax details.
Examples
Uses singly linked lists with Nil and Cons, plus trees with Leaf and Branch, as recursive enum examples.
What you can do after
Build algebraic data types and process their cases with recursive, pattern-matching functions.

Read how Functional Programming in Scala, Second Edition explains enum →

The Design of Web APIs, Second Edition

An enumerated status string is a textual value constrained to one item from a predefined set of status values.

How it is used
Constrains API values while helping consumers interpret account types, filter transactions, and handle statuses.
How deep it goes
Explains value selection and compatibility through API scenarios; identifies JSON Schema enumerations without detailing their syntax.
Examples
Uses checking and savings account types, multi-category transaction filters, transfer statuses, and changes to currency or categorization statuses.
What you can do after
Evaluate/understand when readable enum values help consumers and whether changing allowed input or output values preserves compatibility.

Read how The Design of Web APIs, Second Edition explains enum →

DuckDB in Action

An enum is a data type whose values are restricted to a defined set of named alternatives.

How it is used
Uses fixed-value enums to optimize analytical storage, processing, and filtering of large categorical datasets.
How deep it goes
Explains integer storage, creation, conversion, functions, and query comparisons, but does not detail execution internals.
Examples
Demonstrates weekday values, tag vocabularies, enum lists, membership filters, and top-tag aggregation queries.
What you can do after
Apply it via DuckDB SQL to model categorical values, convert string columns, and query large tag datasets efficiently.

Read how DuckDB in Action explains enum →

Build Financial Software with Generative AI (From Scratch)

An enum type is a database type whose permitted values are defined by a finite named set of labels.

How it is used
Uses finite labels to enforce consistent categories in ACH exceptions and company information schemas.
How deep it goes
Explains declaration, column usage, label extraction, tradeoffs, and a lookup-table alternative, but not enum internals.
Examples
Demonstrates exception severities, tax identifier types, industries, address types, and phone categories.
What you can do after
Build it from scratch in PostgreSQL and evaluate whether a lookup table better fits portability or changing values.

Read how Build Financial Software with Generative AI (From Scratch) explains enum →

Learn Haskell by Example

An enumeration type is an algebraic data type whose constructors are all nullary and whose values form a finite enumerable set.

How it is used
Enumerates nullary constructors for ranges, ordering-based traversal, and numeric conversion.
How deep it goes
Defines Enum methods and derived behavior, but stops short of implementation internals.
Examples
Uses EnumType with A, B, and C plus FileType with Other, Image, and Compressed.
What you can do after
Apply it via derived Enum and Bounded instances to build complete constructor lists and numeric mappings.

Read how Learn Haskell by Example explains enum →

Building User-Friendly DSLs

An enumeration is a language construct that defines a fixed collection of permitted named values.

How it is used
Defines fixed textual choices within an MPS DSL’s structure aspect.
How deep it goes
Defines the construct and gives one concrete value set, but does not detail declaration or code-generation mechanics.
Examples
Uses the Type enumeration with amount, date range, and percentage values.
What you can do after
Evaluate fixed DSL value categories using a concrete enumeration definition.

Read how Building User-Friendly DSLs explains enum →

Data-Oriented Programming in Java

An enum is a Java type construct that defines a fixed set of named constant values.

How it is used
Models fixed domain choices and restricts business-rule attributes to values recognized by the type system.
How deep it goes
Explains enum selection through domain refactoring and shows its use in composite records and rule data, without covering enum behavior or advanced members.
Examples
Uses curing methods in SampleId, measurement grouping, and account attributes in an Equals rule.
What you can do after
Build it from scratch to replace ambiguous strings with named domain values and compose them into typed records or rules.

Read how Data-Oriented Programming in Java explains enum →

Kotlin in Action, 2E

An enum is a Kotlin type whose instances are restricted to a fixed set of named constants.

How it is used
Represents fixed choices and dispatches behavior through when expressions.
How deep it goes
Explains declarations, constructor data, properties, methods, grouped matching, and imports, but stops short of advanced enum mechanics.
Examples
Uses Color constants, RGB values, a color-printing method, a mnemonic function, and sensor-based warmth categories.
What you can do after
Apply it by declaring Kotlin enums with data and selecting exhaustive behavior through when.

Read how Kotlin in Action, 2E explains enum →

The Art of Code

An enum is a language construct that defines a finite set of named constants as a distinct type.

How it is used
Represents fixed, known categories explicitly so data constraints and intent remain visible.
How deep it goes
Explains the modeling rationale and tradeoff with strings or numeric codes, but stops short of syntax or runtime behavior.
Examples
Contrasts enums with free-form strings and numeric codes for representing closed sets of values.
What you can do after
Apply it by modeling fixed categories explicitly and routing limited data-driven variation through clear branching.

Read how The Art of Code explains enum →

Object-Oriented Software Design in C++

A type whose values are restricted to a finite set of named constants.

How it is used
Constrains book genres to a finite set of named values while avoiding string comparison and spelling problems.
How deep it goes
Defines an enum class, demonstrates its constants, and stops short of broader enumeration design concerns.
Examples
Uses book genres including ADVENTURE, CLASSICS, HORROR, and SCIFI in construction and catalogue-search examples.
What you can do after
Evaluate whether a limited attribute should use an enumeration rather than a string.

Read how Object-Oriented Software Design in C++ explains enum →

Code Like a Pro in Rust

An enum is a Rust type that represents a value selected from a defined set of variants, which may carry associated data.

How it is used
Models mutually exclusive states, named choices, and choices carrying variant-specific data.
How deep it goes
Defines variant forms, discriminant casts, and manual numeric conversion, but does not develop broader enum control-flow patterns.
Examples
Uses Japanese dog breeds, explicit numeric variants, Debug output, From<u32>, and mixed named, tuple, and struct-like variants.
What you can do after
Build it from scratch as a Rust enum, attach heterogeneous variant data, derive traits, cast discriminants, and implement numeric conversion.

Read how Code Like a Pro in Rust explains enum →

Write Powerful Rust Macros

An enum is a Rust sum type with a fixed set of named variants that may carry associated data and methods.

How it is used
Models restricted states and makes success-or-failure outcomes explicit in error handling.
How deep it goes
Explains variants, associated data, pattern matching, generics, and a convenience method without descending into representation internals.
Examples
Uses an `Either<T>` result, a calculation returning `Success(42)`, exhaustive matching, and a `map` transformation.
What you can do after
Apply enums to represent recoverable outcomes and handle each variant through pattern matching.

Read how Write Powerful Rust Macros explains enum →

Modern C, Third Edition

An enumeration is a C type that defines a set of named integer values.

How it is used
Names small integer values and stabilizes array indexing without manually tracking entry order.
How deep it goes
Explains positional and explicit values, conversions, and integer constant expressions, but does not develop enumeration storage mechanics.
Examples
Uses corvid names, a designated string array, sequential constants, and valid or invalid constant-expression definitions.
What you can do after
Apply it via named constants and designated array indices while respecting compile-time value constraints.

Read how Modern C, Third Edition explains enum →

Practical Automation with PowerShell: Effective scripting from the console to the cloud

An enumeration is a set of named constants, typically associated with underlying integral values.

How it is used
Uses named constants to supply readable options when PowerShell calls APIs such as Microsoft Word automation.
How deep it goes
Explains integer backing values, qualified syntax, value discovery, and API usage, while deferring custom enumeration design.
Examples
Demonstrates Word table auto-fit modes, GetEnumValues output, table creation, and constrained server-status parameters.
What you can do after
Apply it via PowerShell to select documented API behaviors and inspect valid enum values without relying on numeric codes.

Read how Practical Automation with PowerShell: Effective scripting from the console to the cloud explains enum →

100 C++ Mistakes and How to Avoid Them

An enumeration is a C++ type that defines a set of named integral values representing a finite collection of alternatives.

How it is used
Names finite alternatives such as traffic-light and paint colors instead of unexplained integer values.
How deep it goes
Explains named values, namespace collisions, and enum class declarations through contrasting code examples.
Examples
Contrasts traffic-light and paint colors, including an integer value of 2 and separate enum class groups.
What you can do after
Apply enum class declarations to keep traffic and paint names distinct and qualify values in switches.

Read how 100 C++ Mistakes and How to Avoid Them explains enum →

Grokking Software Architecture

A programming-language type that restricts a value to a predefined set of named options.

How it is used
Clarifies API request meaning by replacing a magic number with a named moderation reason.
How deep it goes
Shows a string enum in a DTO and recommends integer status codes referencing an enum, without detailing implementation.
Examples
Uses a moderation DTO whose reason is “Spam” rather than numeric code 4.
What you can do after
Apply descriptive enum labels to make API values easier for AI to interpret, and reference enums for database status codes.

Read how Grokking Software Architecture explains enum →

Also covered in

What to know first

Related concepts

Questions about enum

What is enum?

An enum is a type whose values are selected from a finite set of named alternatives.

Which Manning books explain enum?

Learn Go with Pocket-Sized Projects, Secure APIs, Python How-To, Refactoring to Rust, 100 Java Mistakes and How to Avoid Them, Rust in Action: Systems programming concepts and techniques, Learn Rust in a Month of Lunches, Essential TypeScript 5, Third Edition and 17 more.

What should I know before learning enum?

Manning books that teach enum usually introduce string, integer, constant and struct first.

What is the difference between enum and aggregate?

An enum is a type whose values are selected from a finite set of named alternatives. A domain-driven design aggregate is a cluster of related domain objects treated as a unit for consistency and state changes, typically accessed through a designated root.

What kinds of enum are there?

Kinds of enum include result type and integer-backed enum.

What is enum a kind of?

Enum is a kind of data structure. A data structure is an organized representation of data and its relationships that supports defined operations for storing, accessing, or modifying it.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.