Polymorphic copy: Difference between revisions

m
Added the Sidef language
No edit summary
m (Added the Sidef language)
Line 1,614:
puts obj1.dup.name # prints "T"
puts obj2.dup.name # prints "S"</lang>
 
=={{header|Sidef}}==
''Sys.copy()'' makes a deep-copy of any object and returns it to the caller.
<lang ruby>class T {
method name {
"T"
}
}
 
class S {
method name {
"S"
}
}
 
var obj1 = T.new;
var obj2 = S.new;
 
say Sys.copy(obj1).name; # prints "T"
say Sys.copy(obj2).name; # prints "S"</lang>
 
=={{header|Slate}}==
2,747

edits