Создать метод, который проверяет ожидаемые типы классов
Пример ниже. Метод check_class
вернет true, как только найдет правильный класс.
Полезно, если вам по каким-либо причинам может понадобиться увеличить количество типов классов.
def check_class(x)
return true if is_string(x)
return true if is_integer(x)
# etc etc for possible class types
return false # Otherwise return false
end
def is_string(y)
y.is_a? String
end
def is_integer(z)
z.is_a? Integer
end
a = "string"
puts "#{check_class(a)}"