replace multimethod

Methods

replace(dst:Any, src:Any)
DISCOURAGED. Replace one object with another. dst and src must be of the same type.

Example

a = [1,2,3]
a.replace([4,5])
a  # [4,5]
replace(e:Eachable1, src:Any, dst:Any) Source: stdlib.ngs:1275
Replace all occurrences of src with dst TODO: Return same type, not Arr

Returns

Arr

Example

["ssh", "IP", "w"].replace("IP", "10.0.0.100")  # ['ssh','10.0.0.100','w']
replace(s:Str, src:Str, dst:Str) Source: stdlib.ngs:4708
Replace all occurrences of src with dst in s
replace(f:File, src:Any, dst:Any) Source: stdlib.ngs:5493
Replace in a file. Wrapper around replace(Str, Any, Any).

Returns

f
replace(s:Str, r:RegExp, mapper:Fun) Source: stdlib.ngs:7226
Replace all occurrences of r

Parameters

mapperFunction that will be called with one matching string at a time that provides the replacement

Returns

Str

Example

"x10ab20c30y".replace(/[0-9]+/, F(match_text) "[$match_text]")  # "x[10]ab[20]c[30]y"
replace(s:Str, r:RegExp, replacement:Str) Source: stdlib.ngs:7236
Undocumented