From: "T. Onoma" Date: 2003-11-25T18:51:00+09:00 Subject: Re: raise unless RUBY_VERSION[%r/^\s*\d+\.\d+/o].to_f >= 1.8 On Tuesday 25 November 2003 10:07 am, Robert Klemme wrote: > "T. Onoma" schrieb im Newsbeitrag > news:200311250002.09555.transami@runbox.com... > > > On Tuesday 25 November 2003 08:07 am, daz wrote: > > > RUBY_VERSION = "1.8.1" > > > p RUBY_VERSION >= "1.8" #-> true > > > RUBY_VERSION = "1.10.1" > > > p RUBY_VERSION >= "1.8" #-> false > > > > > > .... but MINOR 10 would upset RUBY_VERSION_CODE (in version.h) > > > which, incidentally, would be a useful global (eventually). > > > > > > It might take the pressure off Matz if 1.9 didn't have to be > > > followed by 2.0 tho' :-) > > > > > > > unless someone can think of a reason not to - i'll take it! > > > > > > Um, because it's crufty (looks like we can't tell the difference > > > between Numeric and String sorting sequence - even though I've > > > seen it used a lot in Ruby). > > > > Any one think Ruby needs a Tuple class? > > It's already there: Array. No, class Tuple < Array include Comparable end class Array def to_t return Tuple.new(self) end end Now is has a Tuple. Try, ruby_version = RUBY_VERSION.split('.').collect { |i| i.to_i }.to_t puts ruby_version puts ruby_version >= [1,7,1] puts ruby_version >= [1,8] puts ruby_version >= [1,8,1] puts ruby_version >= [1,10] Although a Tuple a.b.c ... literal would look better. -t0