liveBook · Manning

Conditional logic

Conditional logic is a programming technique that selects execution paths, actions, or result values according to evaluated conditions.

How 21 Manning books explain it

Get Programming: Learn to code with Python

A nested conditional is a conditional statement placed inside another conditional's code block so that its evaluation depends on the outer conditional.

How it is used
Uses conditional logic to select code paths and build user-directed story branches.
How deep it goes
Works through single, sequential, nested, and alternative branches, including indentation and Boolean combinations; it does not examine Python internals.
Examples
Traces positive-number checks, nested negative-number checks, and choices in a choose-your-own-adventure program.
What you can do after
Build it from scratch by writing and testing Python conditionals that create different paths through a program.

Read how Get Programming: Learn to code with Python explains conditional logic →

The Well-Grounded Rubyist, Fourth Edition

if is a Ruby conditional construct that executes code when a condition is truthy and can provide alternative branches.

How it is used
Directs Ruby execution according to whether a tested expression is truthy.
How deep it goes
Works through branching, truthiness, expression values, negation, and parse-time assignment behavior.
Examples
Uses keyboard-entered integers to select three branches and a regular-expression match to guard match-data access.
What you can do after
Practice/perform Ruby branching with `if`, `elsif`, `else`, `unless`, and truthy expression results.

Read how The Well-Grounded Rubyist, Fourth Edition explains conditional logic →

100 Java Mistakes and How to Avoid Them

A branching statement is a Java control-flow statement that selects among alternative execution paths.

How it is used
Controls alternative Java execution paths and exposes pitfalls in compact ternary expressions and if–else chains.
How deep it goes
Explains precedence, varargs wrapping, boxing conversions, nested ternaries, and malformed chains, emphasizing prevention and selective static analysis.
Examples
Uses formatted printing, string indentation, null-value display, boxed-number mapping, and data-selection if–else chains.
What you can do after
Diagnose/debug with it by recognizing branch-splitting, precedence, varargs, and boxing failures and choosing safer rewrites.

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

Julia as a Second Language

Conditional execution is the execution of code only when a specified logical condition holds.

How it is used
Uses conditional execution to choose calculations and make a recursive factorial function stop and handle edge cases.
How deep it goes
Works through Boolean checks, `if`, `else`, and ordered `elseif` branches, including the value an executed branch produces.
Examples
Shows REPL comparisons and branch values, then develops a factorial function that distinguishes positive, zero, and negative inputs.
What you can do after
Build it from scratch: write a Julia factorial function with a stopping case, a zero case, and an error for negative inputs.

Read how Julia as a Second Language explains conditional logic →

Python How-To

How it is used
Uses evaluated conditions to filter task titles, choose values, and stop searches when a match appears.
How deep it goes
Works through filtering and conditional loop exits, defines the ternary expression, and poses statement scope as an experiment rather than resolving it.
Examples
Shows urgency-based task filtering, a conditional tag default, a loop that breaks at two, and a scope-check challenge.
What you can do after
Practice/perform condition-based filtering and early loop termination while preserving a result for the no-match case.

Read how Python How-To explains conditional logic →

Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

An if construct conditionally executes a block when its Boolean condition is true.

How it is used
Guides PowerShell scripts toward different actions when parameters, values, or runtime conditions vary.
How deep it goes
Explains Boolean expressions, branch ordering, formatting, and practical function use, but stops short of language internals.
Examples
Uses date and process thresholds, protocol selection, Get-MachineInfo, and a Set-TMServiceLogon exercise.
What you can do after
Builds branching PowerShell functions that select actions, choose connection protocols, and handle fallback cases.

Read how Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools explains conditional logic →

React Quickly, Second Edition

An if/else statement conditionally executes one of two statement branches based on a Boolean expression.

How it is used
Controls which React elements appear for logged-in users, cart contents, verification state, and other UI conditions.
How deep it goes
Explains early returns, ternaries, logical AND, object maps, and component decomposition without descending into JavaScript or React internals.
Examples
Uses countdowns, online status, shopping carts, verified usernames, post-status icons, and nested cart controls.
What you can do after
Apply it via JSX to render alternatives, optional elements, empty states, and nothing when conditions require.

Read how React Quickly, Second Edition explains conditional logic →

Build Python Web Apps with Streamlit

Branching logic is control flow that selects among alternative execution paths based on conditions or decisions.

How it is used
Uses conditions to control actions, interface states, and sequential workflows in Streamlit applications.
How deep it goes
Explains condition tests through button and state examples, but stops short of formal language semantics or advanced branching patterns.
Examples
Demonstrates task addition, a four-state question game, spinners, answer inputs, and correctness feedback.
What you can do after
Apply it via Python and Streamlit to connect user actions or stored state with targeted code and interface outcomes.

Read how Build Python Web Apps with Streamlit explains conditional logic →

Modern C, Third Edition

An if-else statement conditionally selects between alternative statements based on a controlling expression.

How it is used
Controls whether statements execute and selects between alternative code paths during C program execution.
How deep it goes
Defines syntax, branch behavior, truth rules, and comparisons, while deferring the full set of condition primitives.
Examples
Uses comparisons, direct numeric conditions, Boolean simplification, loop filtering, and conditional expressions selecting values or safe function arguments.
What you can do after
Apply C conditions to choose statements, simplify Boolean tests, and select values without evaluating an unused branch.

Read how Modern C, Third Edition explains conditional logic →

Clojure: The Essential Reference

Conditional branching is a control-flow technique that selects which expressions to evaluate according to a condition.

How it is used
Uses selective evaluation to choose results or control whether code runs.
How deep it goes
Defines four core forms, their inputs, outputs, arities, truth rules, and lazy branch evaluation.
Examples
Demonstrates coin tossing, recursive tree-depth calculation, and guarded socket cleanup.
What you can do after
Apply it via Clojure's `if`, `if-not`, `when`, and `when-not` to select expressions and guard operations.

Read how Clojure: The Essential Reference explains conditional logic →

Pro Angular 16

An if/else statement conditionally selects one of two alternative blocks of code.

How it is used
Uses conditional logic to select runtime behavior from alternative code blocks.
How deep it goes
Explains if/else structure, comparison pitfalls, and truthiness, but stops short of deeper control-flow internals.
Examples
Demonstrates name selection using if/else and contrasts equality with identity using numeric and string values.
What you can do after
Apply it via JavaScript or TypeScript if/else statements while avoiding unintended coercion and falsy-value behavior.

Read how Pro Angular 16 explains conditional logic →

Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

A conditional expression is a Terraform expression that evaluates a boolean condition and returns one of two result expressions.

How it is used
Controls optional Terraform infrastructure and selects between configurations through boolean inputs.
How deep it goes
Defines the three-part expression and works through resource and module toggles; defers plan execution behavior.
Examples
Uses a Systems Manager policy attachment, alternative NAT modules, and an optional HTTPS ingress block.
What you can do after
Apply it via Terraform to toggle resources and modules or conditionally include a dynamic block.

Read how Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu explains conditional logic →

The Quick Python Book, Fourth Edition

A conditional statement is a programming-language construct that selects code for execution based on a condition.

How it is used
Controls branching decisions and selects code for execution based on conditional expressions.
How deep it goes
Explains branch ordering, optional clauses, indentation, empty branches, and script-import guards without descending into interpreter internals.
Examples
Uses guess classification, variable assignment, pass, and the __name__ main-script guard as concrete examples.
What you can do after
Apply it via Python to branch on conditions, provide fallbacks, leave placeholders, and protect main-script execution during imports.

Read how The Quick Python Book, Fourth Edition explains conditional logic →

Kotlin in Action, 2E

A Boolean expression is an expression whose evaluation produces a Boolean value.

How it is used
Uses value-producing branches to compute results, choose among alternatives, and replace Java-style ternary expressions.
How deep it goes
Explains expression values, cascading conditions, block results, smart casts, and when refactoring, stopping short of broader control-flow mechanics.
Examples
Demonstrates maximum selection, numeric assignment, recursive expression evaluation, type-based when branches, and logging during evaluation.
What you can do after
Apply it via Kotlin if and when expressions to compute values, evaluate typed expression trees, and structure multi-branch logic.

Read how Kotlin in Action, 2E explains conditional logic →

Modern C

A conditional statement selects whether and which dependent statement or block executes based on a condition.

How it is used
Controls whether a dependent statement runs and selects between alternative code paths.
How deep it goes
Defines syntax, branch behavior, numerical truth rules, and comparisons while deferring complex condition primitives.
Examples
Uses threshold branching, an if-else assignment, and a loop that suppresses output for zero.
What you can do after
Apply conditional execution in C using comparisons, numerical conditions, and alternative branches.

Read how Modern C explains conditional logic →

F# in Action: A Revised Edition of Get Programming with F#

A conditional is a programming construct that selects execution or generated content based on a Boolean condition.

How it is used
Uses if/then expressions to produce values and perform conditional side effects in F# programs.
How deep it goes
Explains expression results, same-typed branches, immutability, and unit-returning exceptions; contrasts if/then with pattern matching.
Examples
Uses age descriptions, Boolean selection, and saving a modified order request.
What you can do after
Apply it via F# if/then expressions to derive values and guard side effects.

Read how F# in Action: A Revised Edition of Get Programming with F# explains conditional logic →

The Art of Code

A conditional is a control-flow construct that selects whether or which instructions execute according to a Boolean condition.

How it is used
Guides control flow while keeping conditional decisions readable and cognitively manageable.
How deep it goes
Explains Boolean conditions through design guidance and a Kotlin implementation, without broader control-flow semantics.
Examples
Uses user eligibility predicates, nested permission handling, and Kotlin book-subtype promotional messages.
What you can do after
Apply it via named methods to simplify dense conditions and choose Kotlin branches for concrete book types.

Read how The Art of Code explains conditional logic →

Learn Haskell by Example

An if-then-else expression is a conditional expression that evaluates one of two branches based on a Boolean condition and must produce a value.

How it is used
Uses conditional expressions to choose transformations and terminate recursive IO actions.
How deep it goes
Defines value-producing branches and same-type IO branches, then limits nested conditionals before introducing guards.
Examples
Uses character rotation, empty-line detection, GHCi evaluation, and recursive input echoing.
What you can do after
Apply it via Haskell expressions to choose pure values or sequence IO actions safely.

Read how Learn Haskell by Example explains conditional logic →

Learn Go with Pocket-Sized Projects

A conditional action is a template control-flow action that selects output based on one or more conditions.

How it is used
Selects output for simple binary conditions in Go and conditional behaviors in templates.
How deep it goes
Defines Go if statements and template if/else chains, without providing a worked conditional-template implementation.
Examples
Uses template actions such as {{ if <cond> }}...{{ else if <cond> }}...{{ else }}...{{ end }}.
What you can do after
Apply it via Go if statements and template actions to select output for binary or chained conditions.

Read how Learn Go with Pocket-Sized Projects explains conditional logic →

Statistics Slam Dunk

An if-else rule is a conditional decision rule that selects one result when a condition holds and another result otherwise.

How it is used
Uses threshold-based rules to turn regression-tree splits into interpretable predictions about regular-season wins.
How deep it goes
Connects each rule to a tree split and traces multiple thresholds, but does not formalize conditional logic beyond regression-tree interpretation.
Examples
Uses points off screens, deflections, and predicted NBA regular-season win ranges as nested conditional examples.
What you can do after
Evaluate regression-tree predictions by following predictor thresholds and comparing the resulting outcome ranges.

Read how Statistics Slam Dunk explains conditional logic →

Elixir in Action, Third Edition

A conditional expression evaluates one of multiple branches according to a condition or a matched pattern.

How it is used
Deploys branching expressions when multiclause functions would be unnecessarily indirect.
How deep it goes
Explains if, unless, and cond behavior, return values, fallbacks, and errors, while connecting case to pattern matching.
Examples
Uses max calculations, notification guards, and call-status classification to demonstrate branching choices.
What you can do after
Apply it via Elixir’s if, unless, cond, case, and multiclause-function forms.

Read how Elixir in Action, Third Edition explains conditional logic →

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.