1 year ago

#289696

test-img

DickWeaselton

Can I use Date components in a variable name in swift and, if so, how?

I am using a struct to store records that include many optional fields, e.g.,

struct record {
    var age: Int?
    var ID: String?
    var firstName: String?
    var lastName: String?
}

Ideally I want to autodeclare a variable named by current date information each time a new record is created, e.g.,

var [Date()] = record()

or whatever would achieve the equivalent end result of...

var _03142022 = record()

I've been unable to locate any examples or relevant analogues and am not certain if I am trying to do something impossible/stupid, or am just failing to find the right search terms.

swift

date

variable-declaration

0 Answers

Your Answer

Accepted video resources