Wednesday, December 21, 2022

[FIXED] What is the := operator?

Issue

In some programming languages, I see (ex.):

x := y

What is this := operator generally called and what does it do?


Solution

In all languages that support an operator := it means assignment.

  • In languages that support an operator :=, the = operator usually means an equality comparison.
  • In languages where = means assignment, == is typically used for equality comparison.

does := mean =?

I can't recall any languages where := means the same as =.


In MySQL := and = are both used for assignment, however they are not interchangeable and selecting the correct one depends on the context. To make matters more confusing the = operator is also used for comparison. The interpretation of = as either assignment or comparison also depends on context.



Answered By - Mark Byers
Answer Checked By - Katrina (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.