[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01859] Re: Another question from a newbie

From: "David Douthitt" <DDouthitt@...>
Date: 2000-03-15 20:29:12 UTC
List: ruby-talk #1859
Thanks for the help!  Now a question on your alternative:

>>> Dave Thomas <Dave@thomases.com> 03/15/00 01:36PM >>>

By the way, there's another fun Ruby trick for doing this kind of
thing. You could code up a simple iterator which only returns
non-blank non-comment lines

   def nonCommentLines(aFile)
      aFile.each { |line|
        line.gsub!(/#.*/, '')
        yield(line) unless line =~ /^\s*$/
      }
   end

   File.open(ENV["ORACONF"]) { |conf|
      nonCommentLines(conf) {  |line|
        print line
      }
   }

>>>snip!<<<

Isn't this alternative more costly in terms of time?  I know OOP isn't known for being fast, but....  It also seems to be much more complex - a yield and gsub! instead of a simple pattern-match.



In This Thread

Prev Next