On 24.05.2009 06:58, Stephan Wehner wrote: > I ran into some unexpected behaviour with the Ruby OptionParser class. > When running this script (without any command line arguments) the output > is as in the last, commented, line. > > -------------------------------------- > > require 'optparse' > options = {} > OptionParser.new do |opt| > opt.on "--ex EXECUTABLE", String do |val| > options[:ex] = val > end > opt.on "--headers" do |val| > options[:headers] = val > end > opt.parse(%w( -help )) In addition to what Brian wrote, the line above is wrongly placed IMHO. You cannot know whether initialization of the OptionParser instance is completed when still inside the block. You should rather invoke #parse on the result of OptionParser.new. > end > > puts options.inspect Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/