From: Xavier Noria Date: 2010-07-21T19:31:26+09:00 Subject: Re: How to check if x is a multiple of y On Wed, Jul 21, 2010 at 12:12 PM, Tom Ha wrote: > what's the most simple solution in Ruby to check if value x is a > multiple of y? That's typically done with the modulus operator, Active Support defines it this way class Integer # Check whether the integer is evenly divisible by the argument. def multiple_of?(number) number != 0 ? self % number == 0 : zero? end end It is special-cased because you can't do modulus 0.