Home > AI > Uncategorized

Self vs self

Self refers to type

self refers to concrete object

Example: in this case, Self = Int, self = 10

extension BinaryInteger {
    func squared() -> Self {
        return self * self
    }
}

let a: Int = 10
print(a.squared())
Related posts:

Leave a Reply