0

I’ve been having a hard time trying to figure out the difference between “:=” and “=” in Solidity. I keep on thinking it is the same thing but I’m not sure about it. Can you please tell me the difference between them and what they are each used for?

2
  • There's nothing special about the := operator in Solidity. It's the same as in all programming languages. See What is the := operator on StackOverflow. Jun 26, 2022 at 10:05
  • Thank you so much for replying! I appreciate that very much.
    – Z Snyder
    Jun 26, 2022 at 17:57

1 Answer 1

0

The = is the assignment operator in solidity. In assembly := is also the assignment operator.

You cannot interchange them, := is invalid in solidity and = is invalid in assembly.

2
  • So what I’m getting is that you should only use := in assembly and only = when it’s not in assembly?
    – Z Snyder
    Jun 26, 2022 at 18:28
  • @ZSnyder It is a syntax error otherwise.
    – Ismael
    Jun 26, 2022 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.