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

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

问题描述

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.在<and的示例. >避免双重渲染错误".

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".

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

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