On Friday 14 February 2003 04:00 pm, Mauricio FernáÏdez wrote: > > class A > > def initialize > > # local variables > > initialize.a ="instead of just a" > > %b = "as sugar for above (used in blocks)" > > # instance variables > > self.c = "instead of @c" > > d = "as above but where self is implied" > > How do I use A#c then if there's @c? indeed, that actually is intentional. the namespace for variables and methods at the same level (instance or class) is the same. thus: self.c = 1 would conflict with: def c 1 end notice what happens though. in either case the result is the same: puts c #--> 1 whether c was defined as an instance variable or an instance method. > Plus I think locals are more used than i.v. so it makes more sense to > prefix the latter... the above is the reason why instance varaibles would loose the prefix. > > > # class variables > > A.e = "instead of @@e" > > @f = "this then could be class variable sugar" > > You forgot my beloved class instance variables :) > > class << A > attr_accessor :e > end > > A.e # class instance variable, NOT class variable technically, these are methods. aren't they? -- tom sawyer, aka transami transami / transami.net