Does someone have a simple rule of thumb about usage of optional?
It keeps popping up in these tutorials and it seems a bit confusing.
Correct me where I'm wrong:
So an optional is var that might be nil at the time you are accessing it.
If a var might be nil, you must use a ?
You unwrap a var with the !
So what if something is nil and you don't use the optional ?
What happens if something is an optional and you don't do a forced unwrap
What happens if you assign an optional to something that's not an optional
If you assign a non optional to an optional, there is no problem, right?
It keeps popping up in these tutorials and it seems a bit confusing.
Correct me where I'm wrong:
So an optional is var that might be nil at the time you are accessing it.
If a var might be nil, you must use a ?
You unwrap a var with the !
So what if something is nil and you don't use the optional ?
What happens if something is an optional and you don't do a forced unwrap
What happens if you assign an optional to something that's not an optional
If you assign a non optional to an optional, there is no problem, right?