ぜのぜ

しりとりしようぜのぜのぜのぜ

109日目

日記

また意味のない週末を過ごしてしまった.土曜日は1週間の疲れを癒やす日だし,日曜日に疲れると月曜日がつらくなるので週末の休みは3日以上ほしい.土曜日にそのまま疲れればいいのか.

今日書いたコード

https://docs.swift.org/swift-book/ReferenceManual/Expressions.html

class Some {
    static let a = "a"
    let b = "b"
}
class Sub: Some {
    static let shared = Sub()
    func f() -> Some { Some() }
}
let x: Some? = Sub().f()
let y: Some = Sub.shared

感想

これは何でわざわざ書かれてるんだ?特別なことではない気がする.

Although it’s common for all of the chained postfix expressions to have the same type, the only requirement is that the whole chained implicit member expression needs to be convertible to the type implied by its context. https://docs.swift.org/swift-book/ReferenceManual/Expressions.html