From: "Bartosz Dziewoński" Date: 2012-09-21T16:28:01+09:00 Subject: Re: How would you allow variable from specific list of Fixnum? I'd use ArgumentError instead of SyntaxError. 2012/9/21, 7stud -- : > 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/. > > -- Wysłane z mojego urządzenia przenośnego -- Matma Rex