@ngn@lemy.lol to Programmer Humor@lemmy.mlEnglish • 1 year agogot himlemy.lolimagemessage-square132fedilinkarrow-up1497arrow-down10
arrow-up1497arrow-down1imagegot himlemy.lol@ngn@lemy.lol to Programmer Humor@lemmy.mlEnglish • 1 year agomessage-square132fedilink
minus-square@AVincentInSpace@pawb.sociallinkfedilinkEnglish4•1 year agowhat if I need to nest if lets
minus-square@RustyNova@lemmy.worldlinkfedilink4•1 year agoUse a match? Unless it’s for guard clauses, a match is fine enough
minus-square@AVincentInSpace@pawb.sociallinkfedilinkEnglish1•1 year agowhat if i need to if let on the result of another if let
minus-square@RustyNova@lemmy.worldlinkfedilink1•1 year agoOh, then you use and_then() or something similar. There’s also the possibility to use the guard clauses patern and do let <...> = <...> else {}. And finally, you can always split into another function. It’s not straight rules. It depends on what makes it more readable for your case.
minus-square@AVincentInSpace@pawb.sociallinkfedilinkEnglish1•1 year agowhat about if on a boolean followed by an if let
what if I need to nest
if let
sUse a
match
? Unless it’s for guard clauses, a match is fine enoughwhat if i need to
if let
on the result of anotherif let
Oh, then you use
and_then()
or something similar.There’s also the possibility to use the guard clauses patern and do
let <...> = <...> else {}
.And finally, you can always split into another function.
It’s not straight rules. It depends on what makes it more readable for your case.
what about
if
on a boolean followed by anif let