Skip to content
ricardoboss edited this page Sep 13, 2023 · 1 revision

Description

clone can be used to create a copy of a value.

Syntax

clone(any subject)
  • subject is the value to be cloned.

Remarks

  • clone is a deep copy, meaning that all nested values are also cloned (in lists and maps)

Examples

list l = [3, 2]
println(l) // [3, 2]
doAdd(l, 1)
println(l) // [3, 2, 1]
list l2 = clone(l)
println(l2) // [3, 2, 1]
doAdd(l, 0)
println(l) // [3, 2, 1, 0]
println(l2) // [3, 2, 1]
Clone this wiki locally