mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Adds initialisation example documentation to structs.
This commit is contained in:
parent
8011b9bcbe
commit
00d617554f
1 changed files with 9 additions and 0 deletions
|
@ -36,6 +36,15 @@
|
|||
// value = value to set the key to (when giving a single key and value)
|
||||
// ---
|
||||
// grow = Set to true to allow structure to grow, or false for new keys to generate an error. Default: true
|
||||
// Example: Create a struct containing just one key-value pair
|
||||
// some_struct = struct_set([], "answer", 42);
|
||||
// // 'some_struct' now contains a single value, 42, under one key, "answer".
|
||||
// Example: Create a struct containing more than one key-value pair. Note that keys and values need not be the same type.
|
||||
// some_struct = struct_set([], ["answer", 42, 2, "two", "quote", "What a nice day"]);
|
||||
// // 'some struct' now contains these key-value pairs:
|
||||
// // answer: 42
|
||||
// // 2: two
|
||||
// // quote: What a nice day
|
||||
function struct_set(struct, key, value, grow=true) =
|
||||
is_def(value) ? struct_set(struct,[key,value],grow=grow)
|
||||
:
|
||||
|
|
Loading…
Reference in a new issue