Override attr_accessor setters in Ruby


Badge-ruby
Rate
1
Posted 11/10/2010 03:48AM by 8_32x32 AlexanderKrenov Star_gold0Star_silver0Star_bronze1

Comments

0
Default_profile_32x32 Colin Thu Nov 11, 2010 10:35PM

That's retarded. Use attr_accessor, which creates a getter AND setter.

0
8_32x32 AlexanderKrenovStar_gold0Star_silver0Star_bronze1 Fri Nov 12, 2010 03:32AM

Yea, I was fog-brained last night when I posted. My point was actually that you can override the built-in setter provided by Ruby using the = sign. I changed the post to reflect...

  • *Wrap code in <sugr></sugr>
Want to learn great syntax? Have great syntax to share? Syntactic Sugr is a community of expert developers sharing syntactic sugar and other powerful snippets.