Nuby question: question marks in method names

This won't work though

...

The problem seems to be that the writer is setting the variable @foo

but

the reader is reading the variable @foo?

Serves me right for not properly testing. Here's an eval based
implementation (tested properly this time :slight_smile:

class Module
  def attr_bool sym
    module_eval <<-CODE
      def #{sym}?; @#{sym}; end
      def #{sym}=(s); @#{sym}=s; end
    CODE
  end
end

thank you very much. :slight_smile:

···

class Module
  def attr_bool sym
    module_eval <<-CODE
      def #{sym}?; @#{sym}; end
      def #{sym}=(s); @#{sym}=s; end
    CODE
  end
end

--
Edwin Eyan Moragas
Main Expectorant

haaktu technologies
spewing spit since '73