From: Derek Ney Date: 2001-10-02T16:49:06+09:00 Subject: [ruby-talk:21930] Question mark in instance variable I recently tried using a question mark as the suffix for an instance variable and discovered problems. I assume that it is just not a good idea, but was curious what was supposed to be happening. With this code snippet: class QTest attr_accessor :shown? end q = QTest.new print "initially q.shown? = ", q.shown?, "\n" q.shown? = true print "q.shown? = ", q.shown?, "\n" I get this: /tmp/test.rb:7: parse error q.shown? = true I have tried all different combos of spaces/nonspaces around the = sign to no avail. However, clearly the internals do support this, it seems to be just a parser problem, because this code works: class QTest attr_accessor :shown? end q = QTest.new print "initially q.shown? = ", q.shown?, "\n" q.__send__("shown?=".intern, true) print "q.shown? = ", q.shown?, "\n" Produces: initially q.shown? = nil q.shown? = true So, is this just a flaw in the parser? Or is it intended? It would be nice if you could use question marks, as it is a very nice feature for methods and has similar uses for instance variables (accessors). This was all with ruby 1.7.1 (2001-09-20). -Thanks, Derek Ney