Why are exclamation marks used in Ruby methods?

后端 未结 10 2209
小蘑菇
小蘑菇 2020-11-22 06:01

In Ruby some methods have a question mark (?) that ask a question like include? that ask if the object in question is included, this then returns a

10条回答
  •  爱一瞬间的悲伤
    2020-11-22 06:11

    ! typically means that the method acts upon the object instead of returning a result. From the book Programming Ruby:

    Methods that are "dangerous," or modify the receiver, might be named with a trailing "!".

提交回复
热议问题