Deepcopy: Difference between revisions

m
(→‎Insitux: implementation)
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
Line 771:
</pre>
 
=={{header|FutureBasic}}==
Translation of FreeBasic
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
 
begin record DeepCopy
NSInteger value1
CFStringRef value2
CFStringRef value3
Boolean value4
double value5
end record
 
local fn DoDeepCopy
DeepCopy a, b
a.value1 = 10
a.value2 = @"A"
a.value3 = @"Okay"
a.value4 = YES
a.value5 = 1.985766472453666
b = a
b.value1 = 20
b.value2 = @"B"
b.value3 = @"Not Okay"
b.value4 = NO
b.value5 = 3.148556644245367
NSLog( @"\nValue of 'a':" )
NSLog( @"a.value1: %ld", a.value1 )
NSLog( @"a.value2: %@", a.value2 )
NSLog( @"a.value3: %@%", a.value3 )
NSLog( @"b.value4: %@", fn BoolString( a.value4 ) )
NSLog( @"a.value5: %.15f", a.value5 )
NSLog( @"\nValue of 'b':" )
NSLog( @"b.value1: %ld", b.value1 )
NSLog( @"b.value2: %@", b.value2 )
NSLog( @"b.value3: %@%", b.value3 )
NSLog( @"b.value4: %@", fn BoolString( b.value4 ) )
NSLog( @"b.value5: %.15f", b.value5 )
end fn
 
fn DoDeepCopy
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
Value of 'a':
a.value1: 10
a.value2: A
a.value3: Okay
b.value4: YES
a.value5: 1.985766472453666
 
Value of 'b':
b.value1: 20
b.value2: B
b.value3: Not Okay
b.value4: NO
b.value5: 3.148556644245367
 
</pre>
 
=={{header|Go}}==
Line 2,412 ⟶ 2,477:
 
In the following example, we attempt to deep-copy a custom type, MyMap, which wraps the built-in generic Map type. This succeeds here because of the types of values used but wouldn't succeed if a Map value were, say, some user-defined type which didn't have a clone() method.
<syntaxhighlight lang="ecmascriptwren">import "./trait" for Cloneable, CloneableSeq
import "./seq" for Lst
 
class MyMap is Cloneable {
9,479

edits