Forum: Ruby Calling a setter method in self (without self.)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tapio K. (Guest)
on 2007-03-13 00:15
(Received via mailing list)

I'm writing a code where it would be desirable to be able to call setter
methods in self without having to specify self explicitly. Like:
x = 0 # calls self.x=, does not assign to a local variable

In Ruby 1.6 this was impossible. Is this still the case in 1.8 and 1.9?
I believe it is, but would like to be sure.

unknown (Guest)
on 2007-03-13 00:31
(Received via mailing list)
On Tue, 13 Mar 2007, Tapio K. wrote:

> --
> Tapio

a work around...

   harp:~ > cat a.rb
   require 'rubygems'
   require 'attributes'

   attribute :x

   x 42

   p x

   harp:~ > ruby a.rb


This topic is locked and can not be replied to.