2

I ran across this piece of code and was wondering what the ? means in this case? It is part of an if statement condition

if user_input.include? "s"

what does the "?" mean?

sorry, i'm new to ruby

lolwuwunoo
  • 81
  • 2
  • That is a ruby convention for methods which return boolean values. Other examples: `.kind_of?` to determine if the object is of a class, `.nil?` to determine if it is nil. The `?` isn't an operator, but rather an actual part of the method name. – Michael Berkowski Nov 25 '14 at 18:51

1 Answers1

6

The ? is part of the method name.

In Ruby, method names are allowed to end in a ? or an !. Typically, ? indicates a predicate (a method that returns a Boolean), and ! indicates a destructive operation (something that modifies the receiver object).

Linuxios
  • 34,849
  • 13
  • 91
  • 116