Ruby 中方法名称末尾的问号是什么意思? [英] What does the question mark at the end of a method name mean in Ruby?

查看:32
本文介绍了Ruby 中方法名称末尾的问号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ruby 中问号运算符的用途是什么?

What is the purpose of the question mark operator in Ruby?

有时看起来像这样:

assert !product.valid?

有时它位于 if 结构中.

sometimes it's in an if construct.

推荐答案

是代码风格的约定;它表示一个方法返回一个布尔值.

It is a code style convention; it indicates that a method returns a boolean value.

问号是方法名称末尾的有效字符.

The question mark is a valid character at the end of a method name.

这篇关于Ruby 中方法名称末尾的问号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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