[#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:01872] Re: Another question from a newbie

From: Dave Thomas <Dave@...>
Date: 2000-03-15 22:21:44 UTC
List: ruby-talk #1872
"David Douthitt" <DDouthitt@cuna.com> writes:

>             next if comment?
                      ^
Should be:            line.comment?



> Now, what's this do:
> 
> next if line.comment?

I _think_ I was suggesting

  nonCommentLines(aFile) do |line|
   # process
  end

instead of

  aFile.each do |line|
    next if line.comment?
    # process
  end

It just seems to encapsulate the comment stripping in one place. If
you wanted to go the whole hog, you might do

   def nonCommentLines(anEnumerable)
     anEnumerable.each do |line|
       yield(line) unless line.comment?
     end
   end

Which then makes the detection of comment lines independent of the
stripping of them, and makes both separate from our application's core 
functionality.

Not a big deal...


Regards


Dave

In This Thread

Prev Next