From: dblack@... Date: 2006-03-26T00:04:36+09:00 Subject: Re: require a certain version of the ruby interpreter Hi -- On Sat, 25 Mar 2006, ara.t.howard@noaa.gov wrote: > On Sat, 25 Mar 2006, Ross Bamford wrote: > >> def ensure_version(v) >> raise "need #{v}" if VERSION.split('.').zip(v.split('.')).any? {|a,b| a < >> b} >> end >> >> (given that we don't need to worry about two-digit versions of course). > > > harp:~ > cat a.rb > def ensure_version(v) > raise "need #{v}" if VERSION.split('.').zip(v.split('.')).any? {|a,b| a < > b} > end > ensure_version "1.8.4" > > > harp:~ > /usr/bin/ruby a.rb > a.rb:2:in `ensure_version': undefined method `zip' for ["1", "6", > "8"]:Array (NameError) > from a.rb:4 > > > my point is that this code does not 'ensure' version 1.8.4 - it blows up > unless > version 1.8.x. I think you've discovered Duck Versioning: [].zip([]) rescue NameError "You need a later Ruby" :-) David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black