From: Logan Capaldo Date: 2006-04-29T09:40:12+09:00 Subject: Re: HTTP:Post and Ruby 1.8.2 On Apr 28, 2006, at 8:22 PM, Jason Persampieri wrote: > On 4/28/06, Logan Capaldo wrote: >> >> >> On Apr 28, 2006, at 7:58 PM, Jason Persampieri wrote: >> >> > Should I check the Ruby version? How would I actually do >> > that? >> > None of my searches paid off. >> >> Should you? That's debatable. Could you? Absolutely. >> >> % ruby -e 'p VERSION' >> "1.8.4" > > > while I guess I *could* call eval and get that, is there a way to > check the > ruby version at runtime? A global var or something? > > I've decided to just change my code to something that works in both > versions, but I'm still curious how to do this :) > > _jason Perhaps my example wasn't clear: #!/usr/bin/env ruby if VERSION >= "1.8.4" # use new HTTP#post elsif VERSION == "1.8.3" # use 1.8.3 #post else # use 1.8.2 #post end __END__ You don't need to call eval, VERSION is a global constant.