liveBook · Manning

String conversion

Also called string representation

String conversion is an operation that transforms a value or representation into its textual string form according to language-defined rules.

How 3 Manning books explain it

JavaScript in Depth

The language process that converts a value to a textual string according to coercion rules.

How it is used
Explains textual coercion and its interaction with comparisons, conditions, numeric operations, and performance-sensitive code.
How deep it goes
Works through primitive and array results, chained coercion, and repeated runtime cost, while deferring detailed object customization.
Examples
Uses String calls, [] == false, conditional execution with [], and numeric sorting of timestamp values.
What you can do after
Diagnose surprising coercion results and avoid repeated conversions through type checking or TypeScript.

Read how JavaScript in Depth explains string conversion →

The Well-Grounded Rubyist, Fourth Edition

String conversion is the derivation of a string or another object representing a string value in a different form.

How it is used
Provides object representations for output, interpolation, inspection, and regular-expression troubleshooting.
How deep it goes
Explains automatic calls, custom definitions, related methods, array exceptions, and regexp notation without exhaustive API coverage.
Examples
Uses irb expressions, a customized Object instance, array output, file output, and regular-expression representations.
What you can do after
Apply it via Ruby's to_s, puts, interpolation, inspect, display, and custom representation methods.

Read how The Well-Grounded Rubyist, Fourth Edition explains string conversion →

Python How-To

A string representation is textual output that describes the value or identity of an object.

How it is used
Improves object inspection, printed output, formatted display, and interactive console readability for class instances.
How deep it goes
Distinguishes __str__ from __repr__, specifies return requirements, and demonstrates both overrides with a Task class.
Examples
Uses a Task object with title, description, and urgency fields to demonstrate print, f-string interpolation, str(), repr(), and console display.
What you can do after
Build it from scratch by overriding __str__ and __repr__ for readable display and informative instance representations.

Read how Python How-To explains string conversion →

Also covered in

Related concepts

Questions about string conversion

What is string conversion?

String conversion is an operation that transforms a value or representation into its textual string form according to language-defined rules.

Which Manning books explain string conversion?

JavaScript in Depth, The Well-Grounded Rubyist, Fourth Edition and Python How-To.

What is string conversion also called?

String conversion is also called string representation.

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.