[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03918] A question about variable names...

From: Dave Thomas <Dave@...>
Date: 2000-07-10 22:31:25 UTC
List: ruby-talk #3918
The rules for name construction seem to be that the first character
(which determines the name's usage) should be an upper or lowercase
letter, a dollar sign or an at sign. The remainder of the name is
drawn from [a-zA-Z0-9_].

So, this means that $3 and @27 and valid names for a global and
instance variable respectively.

   class Dave
     def initialize
     puts n
       @23 = "hello"
     end
     def get
       @23
     end
   end


However, I cannot create a symbol corresponding to the instance
variable "23" - :23 is invalid syntax.

Then... If I create an attribute for my instance variable using

    attr "23"

I can't use it:

   Dave.new.23

is parsed as passing the argument '0.23' to Dave.new.


So... I'm wondering if allowing a digit as the first character after
the @ in an instance variable name is a good idea?

What does the panel think?


Regards


Dave




In This Thread

Prev Next