Skip to content

Commit 074cbef

Browse files
committed
docs: add note concerning broadcasting of nested array elements
1 parent e9f214c commit 074cbef

File tree

1 file changed

+18
-0
lines changed
  • lib/node_modules/@stdlib/array/to-fancy

1 file changed

+18
-0
lines changed

lib/node_modules/@stdlib/array/to-fancy/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,24 @@ y[ '10:20' ] = [ 8, 9, 10, 11 ];
372372
// throws <Error>
373373
```
374374

375+
In order to broadcast a nested array element as one would a scalar, one must wrap the element in a single-element array.
376+
377+
```javascript
378+
var y = array2fancy( [ [ 1, 2 ], [ 3, 4 ] ] );
379+
380+
// Assign individual array elements:
381+
y[ ':' ] = [ 5, 6 ];
382+
var v = y[ ':' ];
383+
// returns [ 5, 6 ]
384+
385+
y = array2fancy( [ [ 1, 2 ], [ 3, 4 ] ] );
386+
387+
// Broadcast a nested array:
388+
y[ ':' ] = [ [ 5, 6 ] ];
389+
v = y[ ':' ];
390+
// returns [ [ 5, 6 ], [ 5, 6 ] ]
391+
```
392+
375393
### Casting
376394

377395
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).

0 commit comments

Comments
 (0)