liveBook · Manning

Enum

An enum is a type or language construct whose values are selected from a finite set of named alternatives, which may carry associated data.

How 23 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
Represents logging levels and character-feedback states as named alternatives.
How deep it goes
Works through named byte types, iota constants, zero-value ordering, and a Stringer method.
Examples
Uses three logger levels and three word-game character hints as concrete implementations.
What you can do after
Build it from scratch using a named Go type and iota constants, choosing an order that makes the zero value useful.

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 related choices into named members for direction inputs, task statuses, and database options.
How deep it goes
Works through Enum construction, member lookup, attributes, iteration, and custom string behavior; contrasts regular class attributes with true members.
Examples
Uses compass directions, a movement function, sortable task statuses, and CSV-versus-SQLite database choices.
What you can do after
Build it from scratch by subclassing Enum, then use members for typed choices, value lookup, iteration, and readable output.

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 fixed outcomes between functions and to represent success or failure without exceptions.
How deep it goes
Works from named variants through payloads and match expressions, then applies the same model to Result and custom error types.
Examples
Refactors a FizzBuzz helper from strings to variants, adds a number-carrying variant, and handles negative input with an error enum.
What you can do after
Build it from scratch: define variants, return them from a function, match their payloads, and represent failures with Result.

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
Models fixed choices in event logs, file states, network states, error types, and VGA colors.
How deep it goes
Works through enum syntax, data-carrying variants, matching, state checks, and error conversion; defers advanced state-machine methods.
Examples
Uses card suits, parsed event logs, mock files, wrapped errors, network states, and VGA colors.
What you can do after
Build it from scratch to represent named alternatives, carry variant-specific data, and check file state before reading.

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
Represents one choice among named variants, including choices stored in structs or used to hold different payload types in one collection.
How deep it goes
Works through declaration, matching, associated data, integer casting, and methods using small examples.
Examples
Uses climate choices, sun-or-stars states, signed and unsigned numbers in a Vec, and a mood-checking method.
What you can do after
Build it from scratch: declare variants, attach data, match on choices, and store different payloads under one enum type.

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 to controlled alternatives for clearer data, flexible filtering, and interoperable consumer contracts.
How deep it goes
Explains readable values, legacy labels, filtering syntax, JSON Schema precision, and compatibility effects without covering implementation internals.
Examples
Uses bank-account types, transaction categories, recurring periods, transfer currencies, and categorization statuses as concrete cases.
What you can do after
Evaluate enumeration choices and apply them to API values, filters, schemas, and compatibility decisions.

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 →

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
Uses named alternatives to make values such as colors readable in automobile and traffic-light code.
How deep it goes
Explains global-name collisions, integer ambiguity, default values, and scoped corrections through contrasting code listings.
Examples
Uses traffic-light colors, automobile paint colors, integer color values, and separate Traffic and Paint enums.
What you can do after
Apply it via enum class to separate related value sets and write qualified switch cases.

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

Related concepts

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.