A common pattern in Ruby is to raise exceptions when a condition is not met. For example, the following code will raise an exception if the number of items in the list is not prime:
- def divisible_by?(number)
- if number % 2 == 0
- raise "Divisible by 2"
- end
Share a personalized message with your friends.