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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3712d39f6a11e9c0dc5a8b17b6a8b466?d=identicon&s=25 Tapio Kelloniemi (Guest)
on 2007-03-12 23:15
(Received via mailing list)
Hi

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.

Thanks!
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2007-03-12 23:31
(Received via mailing list)
On Tue, 13 Mar 2007, Tapio Kelloniemi wrote:

>
> --
> Tapio

a work around...

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

   attribute :x

   x 42

   p x

   harp:~ > ruby a.rb
   42

cheers.

-a
This topic is locked and can not be replied to.