JanetDocsPlaygroundI'm feeling luckyGitHub sign in

table/clone



    cfunction

    (table/clone tab)

    Create a copy of a table. Updates to the new table will not change
    the old table, and vice versa.


1 exampleSign in to add an example
Loading...
(def t @{:a 1 :b 2 :c @[1 2 3]})
(def ct (table/clone t))

(put ct :a 3) # => @{:c @[1 2 3] :a 3 :b 2}
(pp t) # => @{:c @[1 2 3] :a 1 :b 2}

(update ct :c array/concat 4) # => @{:c @[1 2 3 4] :a 3 :b 2}
(pp t) # => @{:c @[1 2 3 4] :a 3 :b 2}
# array under key :c is shared between tables!
pepePlayground