0 6

Prototype pattern.  Copying protocol

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// Enter here the actual content of the snippet. public protocol Copying: class { init(_ prototype: Self) } extension Copying { public func copy() -> Self { return type(of: self).init(self) } } extension Array where Element: Copying { public func deepCopy() -> [Element] { return map { $0.copy() } } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus