Commit 9ce9cdcc authored by Jon Bent's avatar Jon Bent

First commit

parents
import UIKit
class Singleton {
var data: String
init(autoClosure: @autoclosure () -> String){
data = autoClosure()
}
static var shared: Singleton = Singleton(autoClosure: {"autoclosed singleton"}())
}
Singleton.shared.data
extension Sequence where Element == Int {
func double() -> [Int]{
return self.map() {$0 * 2}
}
}
extension Sequence where Element == Double {
func double() -> [Double] {
return self.map() {$0 * 2}
}
}
extension Sequence where Element == String {
func double() -> [String] {
return self.map() {String((Double($0) ?? 0) * 2)}
}
}
print([1,2,3,4].double())
print([1.1,2.2,3.3,4.4].double())
print(["1.1","2.2","3.3","4.4"].double())
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>protocol (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment