โ›”cannot assign value of type 'T' to type 'T'

โญ ๆณจๆ„๏ผš

ไธ‹้ข็š„ init ไธ่ƒฝๅฏซๆˆ init<T>๏ผŒไธ็„ถๆœƒๅผ•้€ฒใ€Œๆ–ฐ็š„ๅž‹ๅˆฅๅƒๆ•ธ Tใ€๏ผˆๆ˜ฏ็š„๏ผŒ่ทŸใ€Œ่ˆŠ็š„ๅž‹ๅˆฅๅƒๆ•ธ Tใ€ๅๅญ—ไธ€ๆจกไธ€ๆจฃ๏ผ‰๏ผŒ็„ถๅพŒ็”ข็”Ÿใ€Œไปคไบบๅ‚ป็œผ็š„้Œฏ่ชค่จŠๆฏใ€๐Ÿ™„๏ผš

โ›” cannot assign value of type 'T' to type 'T'
// non-nominal type wrapper
struct NonnominalType<T> {
    let subject: T
}

extension NonnominalType {
    // โญ ๆณจๆ„๏ผš้€™่ฃกไธ่ƒฝๅฏซๆˆ `init<T>`
    // ไธ็„ถๆœƒๅผ•้€ฒใ€Œๆ–ฐ็š„ๅž‹ๅˆฅๅƒๆ•ธ `T`ใ€๏ผˆๆ˜ฏ็š„๏ผŒ่ทŸใ€Œ่ˆŠ็š„ๅž‹ๅˆฅๅƒๆ•ธ `T`ใ€
    // ๅๅญ—ไธ€ๆจกไธ€ๆจฃ๏ผ‰๏ผŒ็„ถๅพŒ็”ข็”Ÿใ€Œไปคไบบๅ‚ป็œผ็š„้Œฏ่ชค่จŠๆฏใ€๏ผš
    // ใ€Œโ›” cannot assign value of type 'T' to type 'T'ใ€
    init(_ subject: T){
        self.subject = subject
    }
}

Last updated