FIND YOUR NEXT FEW LINES

Results for “mutable”

Small, practical examples. Search by task or narrow things down below.

19 snippets foundClear filters
PythonFunctions & error handling

Avoid a shared mutable default argument

Python: Create a fresh list inside the function when the optional argument is omitted.

Python✓ Tested
PowerShellArray operations

Build a mutable generic list

PowerShell: A generic list supports repeated additions without copying an entire array each time.

PowerShell✓ Tested
PythonMappings & sets

Copy nested mutable data independently

Python: Use deepcopy when changes to nested lists must not affect the original object.

Python✓ Tested
C#Types & reliable control flow

Create a modified copy of an immutable record

C#: A with expression creates a shallow copy with selected changed properties.

C#✓ Tested
JavaRecords & reliable control flow

Define an immutable data record

Java: A local record gives a small Java data carrier named accessors and value semantics.

Java✓ Tested
ReactCustom hooks

Expose immutable collection operations

Expose immutable collection operations with a small React component and explicit browser behavior.

React✓ Tested
ReactRefs & DOM interaction

Keep a mutable value without rendering on each write

Keep a mutable value without rendering on each write with a small React component and explicit browser behavior.

React✓ Tested
RustGetting Started

Modify a value through a mutable borrow

Modify a value through a mutable borrow in a complete Rust program using the standard library.

Rust✓ Tested
RustThreads & shared ownership

Protect shared mutable state with a mutex

Protect shared mutable state with a mutex in a complete Rust program using the standard library.

Rust✓ Tested
C#Collections & data structures

Remove matching items from a mutable list

C#: List.RemoveAll returns how many items it removed.

C#✓ Tested
PythonStructured data & serialization

Return a small immutable named record

Python: Use NamedTuple when callers need both tuple behavior and named fields.

Python✓ Tested
Docker / ComposeImage management

Run an image by its local immutable ID

Docker / Compose: Resolve the local image ID before invoking it.

Docker / Compose✓ Tested