什么是:= 运算符? [英] What is the := operator?

查看:271
本文介绍了什么是:= 运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些编程语言中,我看到(例如):

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

x := y

这个 := 运算符通常被称为什么?它有什么作用?

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

推荐答案

在所有支持运算符 := 的语言中,它意味着赋值.

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.

:= 是指 = 吗?

我不记得有任何语言 :== 的含义相同.

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

在 MySQL 中 :== 都用于 assignment,但是它们不能互换,选择正确的取决于上下文.为了使事情更加混乱,= 运算符也用于 比较.将 = 解释为赋值或比较也取决于上下文.

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.

这篇关于什么是:= 运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆