Not sure what your end goal is but you could use KeyPath here
struct MyCustomType {
let id = 178
let reg = "Expression<String?>(“reg”)"
let date = Date()
func runThis<T>(enter: KeyPath<MyCustomType, T>)
{
print(self[keyPath: enter])
}
}
Example
let x = MyCustomType()
x.runThis(enter: \.id)
x.runThis(enter: \.reg)
x.runThis(enter: \.date)
CLICK HERE to find out more related problems solutions.