“和"之间的区别和&&在红宝石? [英] Difference between "and" and && in Ruby?

查看:31
本文介绍了“和"之间的区别和&&在红宝石?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ruby 中的 &&and 运算符有什么区别?

What is the difference between the && and and operators in Ruby?

推荐答案

and&& 相同,但带有 较低的优先级.他们都使用短路评估.

and is the same as && but with lower precedence. They both use short-circuit evaluation.

警告:and 的优先级甚至低于 =,因此您通常希望避免 and.在和的示例rel="noreferrer">避免双重渲染错误".

WARNING: and even has lower precedence than = so you'll usually want to avoid and. An example when and should be used can be found in the Rails Guide under "Avoiding Double Render Errors".

这篇关于“和"之间的区别和&&在红宝石?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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