define optional string in swift code example Example: declaring optionals swift var myOptional: Any? // any can be replaced with whatever type you need