What is the meaning of “!?” in the declaration on the picture?
!? modifier is used when a parameter must be specified for the API call to make sense, but the value may be
null or empty.
A good example of this is
fromString: it makes no sense to call
fromString without an argument, but
null or empty string could be reasonable.
Thanks! Are the “!” and “?” independent? Can a parameter be optional (i.e., no “!”) and also nullable/bottom (i.e., just “?”)?
If I’m understanding correctly, that is the same behavior as no modifier.
The options are as follows:
- no modifier — parameter is optional, no restrictions on values
!— parameter is required and must have a non-empty value
!?— parameter is required but may have a
nullor empty value