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

From: Andrew Hunt <andy@...>
Date: 2000-03-15 19:37:13 UTC
List: ruby-talk #1858
    >Why does this snippet fail?
    >
    >      class String
    >         def String.comment (str)
    >            str =~ /^(#| *$)/
    >         end
    >      end

Why are you making comment a class method?
It seems to work fine as an instance method:

    class String
     def comment
        self =~ /^(#| *$)/
     end
    end

    File.open("xxx") { |conf|
     conf.readlines.each { |line|
        next if line.comment


Regards,

/\ndy

--
Andrew Hunt, The Pragmatic Programmers, LLC.
Innovative Object-Oriented Software Development
web:   http://www.pragmaticprogrammer.com   email: andy@pragmaticprogrammer.com
--
Our New Book: "The Pragmatic Programmer" Published by Addison-Wesley Oct 1999
              (see www.pragmaticprogrammer.com/ppbook)
--

In This Thread

Prev Next