From: 7stud -- Date: 2012-09-21T14:06:40+09:00 Subject: Re: How would you allow variable from specific list of Fixnum? class ModeError < Exception end class Dog @modes = [1, 4, 17, 20] def self.modes @modes end def initialize(type=nil, location=nil, mode=17) raise ModeError if not self.class.modes.include?(mode) end end Dog.new('x', 'y', 21) --output:-- 1.rb:13:in `initialize': ModeError (ModeError) from 1.rb:17:in `new' from 1.rb:17:in `
-- Posted via http://www.ruby-forum.com/.