HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-29 days agoWhy make it complicated?lemmy.mlimagemessage-square21linkfedilinkarrow-up12arrow-down10file-textcross-posted to: programmerhumor@lemmy.ml
arrow-up12arrow-down1imageWhy make it complicated?lemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-29 days agomessage-square21linkfedilinkfile-textcross-posted to: programmerhumor@lemmy.ml
minus-squareGreatRam@lemmy.worldlinkfedilinkarrow-up0·9 days agoYou’re encoding more information in the typescript one. You’re saying it’s a string that will get updated.
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up0·9 days agoIt’s also valid rust syntax. But if it were rust, this meme would not make sense, since you would just type let a and type inference would do its thing. Which is much more ergonomic.
minus-squarenebeker@programming.devlinkfedilinkEnglisharrow-up0·9 days agolet a = String::from(“Hello, world!”).into() I’ll see myself out.
minus-squareanton@lemmy.blahaj.zonelinkfedilinkarrow-up0·8 days agoAt least be fair and cut out the .into()
minus-squarenebeker@programming.devlinkfedilinkEnglisharrow-up0·8 days agoAnd bow to the compiler’s whims? I think not! This shouldn’t compile, because .into needs the type from the left side and let needs the type from the right side.
minus-squareHaradion@lemmy.mllinkfedilinkarrow-up2·2 days agoIf type constraints later in the function let the compiler infer the type, this syntax totally works.
minus-squarenebeker@programming.devlinkfedilinkEnglisharrow-up1·2 days agoLike if the variable is then used in a function that only takes one type? Huh.
You’re encoding more information in the typescript one. You’re saying it’s a string that will get updated.
That looks like rust ngl
It’s also valid rust syntax.
But if it were rust, this meme would not make sense, since you would just type
let a
and type inference would do its thing. Which is much more ergonomic.let a = String::from(“Hello, world!”).into()
I’ll see myself out.
At least be fair and cut out the
.into()
And bow to the compiler’s whims? I think not!
This shouldn’t compile, because .into needs the type from the left side and let needs the type from the right side.
If type constraints later in the function let the compiler infer the type, this syntax totally works.
Like if the variable is then used in a function that only takes one type? Huh.