Вопросная отметка в Ruby
# methods ending with `?` usually return boolean values (true/false)
# the question mark is just a part of the method's name it's not a special syntax
# It's possible to define a method with a `?` at the end that doesn't return
# boolean values but it's considered a bad practice.
PRIME_NUMBERS = Set[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97].freeze
def prime?(number)
PRIME_NUMBERS.include?(number)
end
prime?(2) #=> true
prime?(1) #=> false
Mateusz Drewniak