HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 1 year agoWhy make it complicated?lemmy.mlimagemessage-square14linkfedilinkarrow-up10arrow-down10file-text
arrow-up10arrow-down1imageWhy make it complicated?lemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 1 year agomessage-square14linkfedilinkfile-text
minus-squareGreatRam@lemmy.worldlinkfedilinkarrow-up0·1 year 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·1 year 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·1 year agolet a = String::from(“Hello, world!”).into() I’ll see myself out.
minus-squareanton@lemmy.blahaj.zonelinkfedilinkarrow-up0·1 year agoAt least be fair and cut out the .into()
minus-squarenebeker@programming.devlinkfedilinkEnglisharrow-up0·1 year 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-up1·1 year agoIf type constraints later in the function let the compiler infer the type, this syntax totally works.
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 aand 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.