I have great experience in IT over 12 years: front / back - ends, mobile, system administration and deployment cycle. I implement effective and great software products.
If you're saying that if let isn't supported in SwiftUI because it's not declarative, then why is the normal if supported? It's even used in the official documentation. To me, both share the same level of "imperativeness", but the if is not as type-safe in this case!
It's clear that SwiftUI it's inspired by other declarative frameworks like React.js or Vue.js, and in those is idiomatic to check if values are present to conditionally render a view. Something like this:
Here, since we are checking that library.address has a value, TypeScript smart casts it from a string? to a normal string. It's the TS equivalent of an if let binding.
I have great experience in IT over 12 years: front / back - ends, mobile, system administration and deployment cycle. I implement effective and great software products.
I wouldn't use React as example of correctness, as it's also not a mature technology.
In case of SwiftUI, I think, they will propose appropriate usage for cases that you aware of.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
if let
– is from another paradigm.The sense of SwiftUI goes to declarative approach, but not into imperative, which is classic.
If you're saying that
if let
isn't supported in SwiftUI because it's not declarative, then why is the normalif
supported? It's even used in the official documentation. To me, both share the same level of "imperativeness", but theif
is not as type-safe in this case!It's clear that SwiftUI it's inspired by other declarative frameworks like React.js or Vue.js, and in those is idiomatic to check if values are present to conditionally render a view. Something like this:
Here, since we are checking that
library.address
has a value, TypeScript smart casts it from astring?
to a normalstring
. It's the TS equivalent of anif let
binding.I wouldn't use React as example of correctness, as it's also not a mature technology.
In case of SwiftUI, I think, they will propose appropriate usage for cases that you aware of.