hello please i need direction on some syntax i usu...
# android
s
hello please i need direction on some syntax i usually unwrap optionals this way want to know if am right in doing so or not.
Copy code
userData.token = response.body()?.token!!
g
There are no optionls. It’s nullable type and null processing always depends. You can just set response type as non-nullable type if it’s the only option (kotlin will throw NPE for you and c ode looks better without
!!
). Also you can replace
body()?
with
body()!!
of your token is non nullable and you want to crash Boot looks like retrofit, so maybe callback-style approach could be a better option, because you shouldn’t handle body reading each time, but have callbacks for success and error. Anyway, always depends on case, there is no universal answer without knowledge of context