[Kde-bindings] String is no longer Enumerable on Ruby 1.9.1

airh2002 airh2002 at oak.dti.ne.jp
Thu Mar 19 13:36:57 UTC 2009


Richard Dale wrote:
> Do we need to do a version test, or 
> will split and puts  work with both like this?
>
> candidates.split("\n").each do |candidate|
>   if candidate =~ /~/ || candidate =~ /qt_metacall/ || candidate =~ 
> /staticMetaObject/
>     next
>   end
>
>   puts candidate.to_ruby_method(showOpt) if pattern.nil? || pattern =~ 
> candidate
> end
>   
On my 1.9.1 environment, above code block and my RUBY_VERSION>= code 
block work both correctly.
(But I try for Qt::Object, Qt::Widget only.)

And more, above code can shrink more Rubyishly like below:

candidates.split($/).each do |candidate|
  if candidate =~ /~|qt_metacall|staticMetaObject/
    next
  end
  puts candidate.to_ruby_method(showOpt) if pattern.nil? || pattern =~ 
candidate
end

# $/ normally equals \n

Youhei Kondou



More information about the Kde-bindings mailing list