function
(put x key val )
Associate `key` with `val` for mutable `x` . Arrays and buffers only
accept non-negative integer keys , and will expand if an out of
bounds value is provided. For an array , extra space will be filled
with `nil` s , while for buffers , 0 bytes are used instead. For a
table , putting a key that is in the table prototype will hide the
association defined by the prototype , but will not mutate the
prototype table. Putting a `nil` value into a table will remove the
table 's corresponding association. Returns `x` .
(put @{:a 4 :b 5 } :c 6 ) # => @{:a 4 :b 5 :c 6}
(put @{:a 4 :b 5 } :b nil ) # => @{:a 4}
(put @{:a 4 :b 5 } :z nil ) # => @{:a 4 :b 5}
(put @[:a :b :c ] 0 :z ) # => @[:z :b :c]
(put @[:a :b :c ] 1 nil ) # => @[:a nil :c]
(put @[:a :b :c ] 5 :d ) # => @[:a :b :c nil nil :d]
(put @"hello" 0 "z" ) # error: can only put integers in buffers
(defn ord [ch ] (first (string/bytes ch )))
(ord "z" ) # => 122
(put @"hello" 0 122 ) # => @"zello"
(put @"hello" 0 (ord "z" ) ) # => @"zello"
(put @"hello" 8 (ord "y" ) ) # => @"hello\0\0\0y"
(put (table ) :a 1 ) # => @{:a 1}