This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@available(iOS 10.0, *) | |
extension MyClass {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let t: AnyClass = NSObject.self | |
typealias T = t // Use of undeclared type 't' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol P1 { | |
} | |
protocol P2 { | |
typealias A = P1 // Selfでも同様 | |
} | |
let arr1: Array<P1> = [] | |
let arr2: Array<P2> = [] // Protocol 'P2' can only be used as a generic constraint because it has Self or associated type requirements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol P1 { | |
} | |
protocol P2 { | |
typealias A = Self | |
} | |
let arr1: Array<P1> = [] | |
let arr2: Array<P2> = [] // Protocol 'P2' can only be used as a generic constraint because it has Self or associated type requirements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol P: Hashable {} | |
func ==(lhs: S, rhs: S) -> Bool { return lhs.name == rhs.name } | |
struct S: P { | |
var name = "struct" | |
var hashValue: Int { get{ return name.hash } } | |
} | |
let setS: Set<S> = [S()] | |
let setP: Set<P> = [S()] // Protocol 'P' can only be used as a generic constraint because it has Self or assosiated type requirements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override static func initialize() { | |
struct Static { | |
static var token: dispatch_once_t = 0 | |
} | |
struct SwizzlingSelector { | |
let original:Selector | |
let swizzled:Selector | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Location { | |
var x:Int | |
var y:Int | |
} | |
var l1 = Location(x: 10, y: 20) | |
l1.x = 30 | |
let l2 = Location(x: 10, y: 20) | |
l2.x = 30 // Cannot assign to property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sum: ([Int]) -> Int | |
sum = { values in | |
if values.isEmpty { | |
return 0 | |
} | |
else { | |
return values.first! + sum(Array(values.dropFirst())) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HTMLElement { | |
let name: String | |
let text: String? | |
// プロパティでasHTMLへのstrong参照を持っている | |
lazy var asHTML: Void -> String = { // nameとtextを使いたいからlazy | |
// Closure内でselfのプロパティをキャプチャしている | |
if let text = self.text { | |
return "<\(self.name)>\(text)</\(self.name)>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias imgdiff='composite -compose difference' |