Variable declaration with underscore

Viewed 1269

I have seen this in some videos on Youtube.

class Student {

    private var _name: String!
    private var _studentID: Int!

    var name: String {
        return _name
    }

    var studentID:Int {
        return _studentID
    }

    init(name: String, studentID: Int) {
        self._name = name
        self._studentID = studentID
    }
}

Any reason why they are doing this (adding _name and _studentID) instead of:

class Student {

    private var name: String!
    private var studentID: Int!

    init(name: String, studentID: Int) {
        self.name = name
        self.studentID = studentID
    }
}

Thank you very much.

1 Answers
Related