From: Stephan Wehner Date: 2009-05-25T15:42:58+09:00 Subject: Re: OptionParser: unexpected behaviour with -help Robert Klemme wrote: > On 24.05.2009 06:58, Stephan Wehner wrote: >> 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 Good point -- but the result is the same. Stephan > Kind regards > > robert -- Posted via http://www.ruby-forum.com/.