What Does the "?" at the End of the Ruby Array#include? Method Mean?

The Ruby Array#include? method has a question mark symbol after the method name because it returns a boolean value (i.e. true/false):

array = ["foo", "bar", "baz"]

puts array.include?("foo") #=> true
puts array.include?("qux") #=> false

In Ruby, method names ending with a question mark (?) is a naming convention for methods that either return true/false, or an object to indicate a true value (or "truthy" value).

Please note that this convention only applies to method names and not variables.

Hope you found this post useful. It was published . Please show your love and support by sharing this post.