set

set collection's item at index to given value


Parameters

set collection :string :binary :dictionary :object :store :block :bytecode
    index :any
    value :any

Attributes

safeset value, overriding potential magic methods (only for Object values)

Returns

  • :nothing

Examples

copy
myDict: #[ name: "John" age: 34 ] set myDict 'name "Michael" ; => [name: "Michael", age: 34]

copy
arr: [1 2 3 4] set arr 0 "one" ; => ["one" 2 3 4] arr\1: "dos" ; => ["one" "dos" 3 4] x: 2 arr\[x]: "tres" ; => ["one" "dos" "tres" 4]

copy
str: "hello" str\0: `x` print str ; xello

copy
define :person [ set: method [what, value][ ; do some processing... set.safe this what value ; and actually set the value internally ] ]

Related