liveBook · Manning

Slicing

Also called slice

Slicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions.

How 16 Manning books explain it

100 Go Mistakes and How to Avoid Them

Slicing is the Go operation that selects a half-open range of elements from an array or slice.

How it is used
Uses slicing to examine shared-array side effects and memory retention in Go.
How deep it goes
Traces slice length, capacity, backing-array sharing, append behavior, and retention; compares full slice expressions, copying, and clearing references.
Examples
Traces an append that overwrites a sibling slice and a two-element subslice that retains 998 byte-slice allocations.
What you can do after
Diagnose/debug unintended mutations and retained memory, then choose capacity limiting, copying, or clearing references as appropriate.

Read how 100 Go Mistakes and How to Avoid Them explains slicing →

Learn Rust in a Month of Lunches

A slice is a dynamically sized borrowed view of a contiguous sequence of values.

How it is used
Uses borrowed views to work with portions of arrays, strings, and vectors without taking ownership of their data.
How deep it goes
Explains range syntax, string-slice representation, and lifetime errors through examples, while deferring detailed Deref treatment.
Examples
Shows array ranges, string-slice function arguments, overlapping windows, and a vector split into mutable slices.
What you can do after
Apply slicing in Rust to select array ranges, pass string views, and split vectors.

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

Rust in Action: Systems programming concepts and techniques

A slice is a dynamically sized, fixed-length view of contiguous elements that does not own or resize the underlying storage.

How it is used
Introduces slices alongside arrays and vectors to support a text-search program with surrounding context lines.
How deep it goes
Explains slice types, fixed lengths, views, and pointer-and-length references, then demonstrates copying into a memory range.
Examples
Uses a line-by-line text search, a password-length check, and instruction bytes loaded into emulator memory.
What you can do after
Apply slices in Rust to access data through views and copy bytes into a memory range.

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

Go in Action, Second Edition

A slice expression is Go syntax that creates a slice view over an index range of an array or slice while sharing the underlying storage.

How it is used
Uses slice expressions to select shared portions of collections for processing and function calls.
How deep it goes
Explains bounds, omitted indices, backing storage, slice headers, and three-index capacity limits with worked examples.
Examples
Demonstrates averaging ten sensor readings and iterating over filename arguments with os.Args[1:].
What you can do after
Apply slice expressions to select ranges, limit capacity, and pass subsets to functions.

Read how Go in Action, Second Edition explains slicing →

Refactoring to Rust

A slice is a non-owning view of a contiguous region of elements represented by a pointer and a length.

How it is used
Uses borrowed views to access strings and shared C memory without reallocating the viewed data.
How deep it goes
Explains pointer-and-length representation, conversion costs, lifetime relationships, and constructing views from raw parts.
Examples
Uses String-to-&str conversion and an NGINX request-body function to illustrate borrowed views.
What you can do after
Apply slices in Rust to pass string views and understand borrowed data at a C interface.

Read how Refactoring to Rust explains slicing →

Code Like a Pro in Rust

A Rust slice is a dynamically sized view of a contiguous region of values of one type, represented with a pointer and a length.

How it is used
Uses slices as borrowed sequence views for splitting, string arguments, and bulk copying.
How deep it goes
Explains pointer-and-length representation, vector dereferencing, borrow conflicts, and the standard-library copying implementation.
Examples
Demonstrates splitting a byte array, a rejected vector resize, and a bulk-copy benchmark.
What you can do after
Apply slicing with Rust’s standard library to borrow sequences, split them, and copy equal-length slices.

Read how Code Like a Pro in Rust explains slicing →

Tiny Python Projects: Learn coding and testing with puzzles and games

How it is used
Uses slices to extract, rearrange, and reconstruct portions of strings and lists during small Python programs.
How deep it goes
Explains zero-based indexes, omitted boundaries, excluded stops, negative indexes, and immutable-string workarounds, but not tensor-specific slicing.
Examples
Demonstrates prefixes, suffixes, list subranges, string replacement, verse gifts, word stemming, and scrambled word middles.
What you can do after
Apply it via Python slice notation to select subranges and reconstruct strings without direct character assignment.

Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains slicing →

Learn Go with Pocket-Sized Projects

A slice is a dynamically sized view over the elements of an underlying Go array, represented by a pointer, length, and capacity.

How it is used
Uses slices to collect, iterate over, sort, and test variable-length collections in practical Go programs.
How deep it goes
Explains arrays, pointers, length, capacity, make, append, nil slices, ranging, and sorting operations.
Examples
Demonstrates shared-book collection, book recommendations, JSON input, slice initialization, ranging, sorting, and table-driven tests.
What you can do after
Build it from scratch by creating, growing, iterating over, sorting, and testing slices in Go applications.

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

Python Workout: 50 ten-minute exercises

How it is used
Uses slicing to retrieve and process parts of Python strings, lists, tuples, and other sequence-like values.
How deep it goes
Explains bounds, steps, omitted indexes, type preservation, and forgiving ranges, but does not descend into implementation internals.
Examples
Uses alphabetic strings, first-and-last sequence functions, accumulation with items[1:], Pig Latin, and hexadecimal reversal.
What you can do after
Apply Python slice syntax to select ranges, steps, prefixes, suffixes, and remaining sequence elements in runnable code.

Read how Python Workout: 50 ten-minute exercises explains slicing →

Get Programming: Learn to code with Python

How it is used
Uses slicing to select string substrings and extract first and last names for a name-mashup program.
How deep it goes
Defines start, stop, and step, explains excluded stop bounds and step direction, and applies slicing to split names.
Examples
Uses student records, character groups in “snap crackle pop,” and first- and last-name extraction.
What you can do after
Apply slicing to extract substrings and separate first and last names.

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

Python How-To

How it is used
Retrieves subsequences from sequence data and supports modifying subsequences in mutable sequences.
How deep it goes
Explains bounds, omitted indices, strides, slice objects, and mutable-sequence edits with practical examples.
Examples
Uses fruit and number lists, monthly revenue, and a challenge involving strings, tuples, and ranges.
What you can do after
Apply Python slicing to select subsequences with bounds and steps, reuse slice objects, and edit mutable sequences.

Read how Python How-To explains slicing →

The Quick Python Book, Fourth Edition

How it is used
Uses Python sequence notation to extract portions of lists and strings, and to edit list regions.
How deep it goes
Explains slice bounds, omitted endpoints, negative indices, empty reverse ranges, and list assignment; treats lists and strings rather than multidimensional arrays.
Examples
Demonstrates extracting list subsegments, copying and resizing lists, and chopping a newline from a string.
What you can do after
Apply slicing to extract, copy, replace, insert, or remove list regions and extract string substrings.

Read how The Quick Python Book, Fourth Edition explains slicing →

Learn AI-Assisted Python Programming, Second Edition

How it is used
Selects portions of strings and lists, then supports word-generation subtasks.
How deep it goes
Defines exclusive endpoints and omitted bounds, then applies slicing within insertion and replacement functions.
Examples
Demonstrates books[1:3], omitted bounds, and word insertion or replacement using sliced strings.
What you can do after
Apply slicing in Python to extract list or string ranges and construct modified words.

Read how Learn AI-Assisted Python Programming, Second Edition explains slicing →

Idiomatic Rust

A slice is a dynamically sized view of a contiguous sequence without owning the underlying storage.

How it is used
Uses slices to expose contiguous data through accessors and accept varied collection types in function inputs.
How deep it goes
Compares Vec- and slice-based input signatures and demonstrates a slice-returning accessor, staying at the interface level.
Examples
Demonstrates a pizza-toppings accessor, flexible collection inputs, and string reversal using &str.
What you can do after
Apply slices by accepting &[T] instead of &Vec<T> in library function interfaces.

Read how Idiomatic Rust explains slicing →

Julia as a Second Language

Array slicing is the selection of one or more elements or subarrays from an array by specifying index ranges or positions.

How it is used
Uses index positions and ranges to extract or modify elements, rows, columns, and subarrays.
How deep it goes
Explains one- and two-dimensional syntax, begin/end indexing, copy semantics, views, and underlying indexing functions.
Examples
Demonstrates vector ranges, begin/end positions, matrix row and column selection, copied slices, and @view mutations.
What you can do after
Apply it via Julia indexing syntax to select array data, preserve or share storage, and avoid unnecessary copies.

Read how Julia as a Second Language explains slicing →

Go in Practice, Second Edition

How it is used
Uses slices for homogeneous, variable-length collections in command-line validation and generic data processing.
How deep it goes
Defines slices against arrays and demonstrates validation and filtering, without detailing range expressions or slice internals.
Examples
Demonstrates validating language codes and filtering slices of strings and integers.
What you can do after
Apply slices to validate allowed values and filter collections with generic functions.

Read how Go in Practice, Second Edition explains slicing →

Also covered in

What to know first

Related concepts

Questions about slicing

What is slicing?

Slicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions.

Which Manning books explain slicing?

100 Go Mistakes and How to Avoid Them, Learn Rust in a Month of Lunches, Rust in Action: Systems programming concepts and techniques, Go in Action, Second Edition, Refactoring to Rust, Code Like a Pro in Rust, Tiny Python Projects: Learn coding and testing with puzzles and games, Learn Go with Pocket-Sized Projects and 8 more.

What should I know before learning slicing?

Manning books that teach slicing usually introduce string, array, list and reference first.

What is the difference between slicing and array?

Slicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions. An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.

What is slicing also called?

Slicing is also called slice.

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.