[]= multimethod

Methods

[]=(arr:Arr, range:NumRange, replacement:Arr)
Set array elements at specified indexes.

Returns

replacement
[]=(arr:Arr, idx:Int, v:Any)
Set element at the given index or throw IndexNotFound if the index is out of range.

Returns

v
[]=(s:Str, range:NumRange, replacement:Str)
Change substring

Returns

replacement

Example

s="abcd"; s[1..3]="X"; s  # "aXd"
[]=(h:Hash, k:Any, v:Any)
Set hash value.

Parameters

hTarget hash
kKey
vValue

Returns

v

Example

h = {"a": 1}
h["a"] = 2
h["a"]  # 2
[]=(al:ArrLike, idx:Int, x:Any) Source: stdlib.ngs:721
Get element from the underlying array.
[]=(hl:HashLike, k:Any, v:Any) Source: stdlib.ngs:781
Set value.

Automatically called by NGS for syntax

your_hashlike[k] = v
[]=(arr:Arr, r:PredRange, replacement:Arr) Source: stdlib.ngs:2115
Replace array elements.

Parameters

arrArray to operate on.
rRange of elements to replace.
replacementNew elements.

Example

a = %[a1 a2 b1 b2]
a[/^a/.../^b/] = [7]  # a == [7, 'b2']
MARKERS = '# generated - start'..'# generated - end'
text[MARKERS] = newly_generated_content_lines
[]=(h:Hash, k:Any, v:Any)
Setting same key twice is a bug. If it happens, augment_types() works on one objects but other objects are used later.