将'dateFormatter'评估一次,就像懒惰一样?
class Birthday {
private static var dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "d MMMM yyyy"
return formatter
}()
private let date: Date
init(date: Date) {
self.date = date
}
}
ASDF