[fxruby-users] setting widget attributes
r.mark.volkmann at gmail.com
Tue Mar 28 16:14:35 EST 2006
On 3/28/06, Mark Volkmann <r.mark.volkmann at gmail.com> wrote:
> On 3/28/06, Lyle Johnson <lyle at knology.net> wrote:
> > On Mar 28, 2006, at 1:32 PM, Mark Volkmann wrote:
> > > However, if I do this
> > >
> > > self.visibleRows = 5
> > >
> > > then it does.
> > >
> > > Shouldn't it work without "self."?
> > Nope, and this is a Ruby thing (not particular to FXRuby, I mean). When
> > you do:
> > visibleRows = 5
> > Ruby assumes that you're initializing a local variable. You only invoke
> > the accessor method for the visibleRows attribute when you prepend it
> > with self (as you've discovered).
> Since visibleRows is listed as an RW "attribute" in the RDoc, I
> thought that implied there were methods named "visibleRows" and
> visibleRows=" available. That's what I thought I was invoking with
> "visibleRows = 5". If those methods existed then Ruby wouldn't have
> thought I wanted to initialize a local variable. Right?
> Since those accessor methods don't exist, I'll just use "@visibleRows = 5".
Eeek! This doesn't work. I'm so confused.
Is visibleRows an instance variable of FXTable?
If so, why can't I access it directly from a subclass with "@visibleRows"?
Does it have accessor methods?
If so, why can't I invoke them directly from a subclass without using "self."?
Sorry to ask basic Ruby questions. I thought I understood this, but
R. Mark Volkmann
Object Computing, Inc.
More information about the fxruby-users