Syntactic sugar
Syntactic sugar is language syntax that provides a more convenient or readable form for expressing behavior already representable by other constructs without changing its meaning.
The Well-Grounded Rubyist, Fourth Edition
Syntactic sugar is a language feature that provides a more convenient or readable syntax for expressing an operation supported by the language's ordinary rules.
- How it is used
- Makes Ruby method calls read like assignment, arithmetic, indexing, or other familiar operations.
- How deep it goes
- Explains the method calls behind setter and operator notation, including custom definitions, shortcuts, semantic pitfalls, and non-overridable operators.
- Examples
- Uses a ticket price setter, normalized travel year, custom `+`, bank-account `-=`, and arithmetic written as explicit method calls.
- What you can do after
- Build it from scratch by defining setter or operator methods, and diagnose/debug surprising operator behavior by checking those methods.
Read how The Well-Grounded Rubyist, Fourth Edition explains syntactic sugar →
Secrets of the JavaScript Ninja, Second Edition
Language syntax that makes an operation easier to read or write without adding new underlying capabilities.
- How it is used
- Makes class-like object setup, function expressions, and iterator traversal shorter or clearer to write.
- How deep it goes
- Defines the idea through three comparisons, including class-to-prototype mechanics and iterator next/done handling.
- Examples
- Uses a Ninja class, a sorting callback, and a generator loop to compare concise syntax with its mechanics.
- What you can do after
- Understand how class, arrow-function, and for-of forms relate to prototypes, function expressions, and iterator operations.
Read how Secrets of the JavaScript Ninja, Second Edition explains syntactic sugar →
Related concepts
- classequivalent to · A class is a programming-language construct that defines a type’s structure or behavior and provides a basis for creating or representing objects.
- accessor methodused by · An accessor method or function provides access to an object's property or state by retrieving its value, assigning a value, or defining behavior for such access.
- method callcontrasts with · A method call is an expression that invokes a method associated with an object, value, or type, optionally supplying arguments.
- decoratorequivalent to · A decorator is a programming-language construct that adds metadata or behavior to, or transforms, a program declaration, often a function or class.
- function overloadingincludes · Function overloading is defining multiple callable operations with the same name but different parameter signatures, with behavior selected according to the call.
- do notationincludes · Do notation is Haskell syntax for sequencing monadic computations and binding their intermediate results in a readable, imperative-like form.
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.

