From 5e92601ab44359b2ad196d9f9df6b221f4a1c397 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Jun 2024 08:44:12 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 1 + README.md | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c4239..72dfd67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@
+- [`074cbef`](https://github.com/stdlib-js/stdlib/commit/074cbef3f9d616c37c2be856a949e257481ff2fc) - **docs:** add note concerning broadcasting of nested array elements _(by Athan Reines)_ - [`b079d65`](https://github.com/stdlib-js/stdlib/commit/b079d653226019925581555fdaf9aa927ec69c0e) - **feat:** add support for integer array indexing assignment _(by Athan Reines)_ - [`96e896a`](https://github.com/stdlib-js/stdlib/commit/96e896a39be08912b2e06dfb6b671ec13d042412) - **feat:** add support for boolean array indices _(by Athan Reines)_ - [`75d4f83`](https://github.com/stdlib-js/stdlib/commit/75d4f83cb85610d23a04dc21a03f8075f6d3665f) - **refactor:** update require and include paths _(by Athan Reines)_ diff --git a/README.md b/README.md index 4e50509..19a7d8f 100644 --- a/README.md +++ b/README.md @@ -405,6 +405,24 @@ y[ '10:20' ] = [ 8, 9, 10, 11 ]; // throws ``` +In order to broadcast a nested array element as one would a scalar, one must wrap the element in a single-element array. + +```javascript +var y = array2fancy( [ [ 1, 2 ], [ 3, 4 ] ] ); + +// Assign individual array elements: +y[ ':' ] = [ 5, 6 ]; +var v = y[ ':' ]; +// returns [ 5, 6 ] + +y = array2fancy( [ [ 1, 2 ], [ 3, 4 ] ] ); + +// Broadcast a nested array: +y[ ':' ] = [ [ 5, 6 ] ]; +v = y[ ':' ]; +// returns [ [ 5, 6 ], [ 5, 6 ] ] +``` + ### Casting Fancy arrays support [(mostly) safe casts][@stdlib/array/mostly-safe-casts] (i.e., any cast which can be performed without overflow or loss of precision, with the exception of floating-point arrays which are also allowed to downcast from higher precision to lower precision).