Any Swift programming language developers here? I notice that there is some grammatical inconsistency with the language.
Within the 'if' statement, you don't need to force unwrap 'contantName' to access the value in 'someOptional'. In other words, the right side of the assignment is an optional, while the left side is a non-optional.
But in other context, both sides of the assignment have to be optionals:
You need to force unwrap 'anotherOptional' to access the value in 'someOptional'.
To access the value of the same option, you do this:
In the first statement, the left side of the assignment is an optional while the right side is a literal. They are not the same data types. To be grammatically consistent, it should be:
I yearn for the good old days of the C programming language, where the grammar of the language is highly consistent.
Example 1
Take for example optional binding:if let constantName = someOptional {
...
}
Within the 'if' statement, you don't need to force unwrap 'contantName' to access the value in 'someOptional'. In other words, the right side of the assignment is an optional, while the left side is a non-optional.
But in other context, both sides of the assignment have to be optionals:
anotherOptional = someOptional
You need to force unwrap 'anotherOptional' to access the value in 'someOptional'.
Example 2
To assign a value to an optional, you do this:optionalInteger = 42
To access the value of the same option, you do this:
optionalInteger! // 42
In the first statement, the left side of the assignment is an optional while the right side is a literal. They are not the same data types. To be grammatically consistent, it should be:
optionalInteger!=42
My rant
These types of grammatical inconsistencies increases the cognitive load on programmers!!I yearn for the good old days of the C programming language, where the grammar of the language is highly consistent.