Predicate Methods
Learn about the predicate methods in Ruby and how to use them.
Predicate methods
If we look at the list of methods defined for a String
object, we see that there are methods that end with a question mark (?
).
In Ruby convention, these methods return either true
or false
. For example, we can ask a number if it’s even or odd:
Press + to interact
Ruby
puts 5.odd?puts 5.even?
This makes ...