Calling a setter method in self (without self.)

T

Tapio Kelloniemi

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!
 
A

ara.t.howard

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!

a work around...

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

attribute :x

x 42

p x

harp:~ > ruby a.rb
42

cheers.

-a
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top