Sjmarf@sh.itjust.works to Programmer Humor@programming.dev · 8 months agoUnused variablessh.itjust.worksimagemessage-square52fedilinkarrow-up1898arrow-down119
arrow-up1879arrow-down1imageUnused variablessh.itjust.worksSjmarf@sh.itjust.works to Programmer Humor@programming.dev · 8 months agomessage-square52fedilink
minus-squareRichard@lemmy.worldlinkfedilinkEnglisharrow-up1·8 months agoWhat do you mean? Variables do not necessarily need to be used, you can allocate memory for some value and initialise it but then simply don’t do anything with it.
minus-squareDacoTaco@lemmy.worldlinkfedilinkarrow-up2·8 months agoYou can but compilers will optimise that away unless you tell it not to.
minus-squareShareni@programming.devlinkfedilinkarrow-up1·8 months agoMeanwhile go: you will remove it or I won’t compile, unless you know the secret handshake
minus-squareRagingRobot@lemmy.worldlinkfedilinkarrow-up1·8 months agoYes you can but the little red squiggles show in your editor to warn you that it’s unused code. That’s what the whole post is about lol
What do you mean? Variables do not necessarily need to be used, you can allocate memory for some value and initialise it but then simply don’t do anything with it.
You can but compilers will optimise that away unless you tell it not to.
Meanwhile go: you will remove it or I won’t compile, unless you know the secret handshake
Yes you can but the little red squiggles show in your editor to warn you that it’s unused code. That’s what the whole post is about lol