Lasso Soft Inc. > Home

[ any->ascopydeep ]

Method

The [any->asCopyDeep] method returns a deep copy of an object. In general, the [any->asCopy] method is sufficient, but in the rare circumstance when an isolated, exact copy is needed, the [any->asCopyDeep] method provides jus that.

In Lasso, a type has depth if it contains other objects, so the [integer] and [string] types, for example, have no depth. This means that [any->asCopy] is the same as [any->asCopyDeep] for these types. Other types, such as the [array] type, do contain other objects and therefore have depth. To read more about shallow copying and its effect on types that have depth, please see the [any->asCopy] method description.

  • Syntax
local(obj) = my_object(...)
#obj->asCopyDeep
Examples
  • Beginner

Demonstrating a deep copy

The code below demonstrates what happens with a deep copy. The result will show that the copied array's elements are different than the original's.

Code

local(original) = array('radish', 'carrot', 'cucumber', 'olive')
local(copy)     = #original->asCopyDeep
iterate(#original) => {
    loop_value->uppercase
}
#original
'<br>'
#copy

Result

array(RADISH, CARROT, CUCUMBER, OLIVE)
array(radish, carrot, cucumber, olive)

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft