3 ms·
Yes. That's why a good language makes this explicit in the type. For example in Scala, this example would be that user is of type Option[User] and the name pro
by terryf 8y ago
Yes. That's why a good language makes this explicit in the type.
For example in Scala, this example would be that user is of type Option[User] and the name property would also be Option[String] for example.
Then to safely get the name would be:
user.flatMap(_.name)
and the resulting type would be Option[String]
Which would then carry on the info that you don't know for certain that you know the name.