In ruby, is truthiness idiomatic for a method name ending with a question mark?

后端 未结 4 1972
情深已故
情深已故 2021-02-13 21:33

Is it normal for methods with a question mark to return something that\'s truthy (for example, a number) to indicate that something is true, or should true itself b

4条回答
  •  情书的邮戳
    2021-02-13 22:23

    Adding a ? to a method name in Ruby is idiomatic that the method will return true or false. Object#nil? is a good example. In fact, Object has a lot of good examples of truthiness checks.

提交回复
热议问题