[fxruby-users] method call question

Lyle Johnson lyle at lylejohnson.name
Wed Oct 29 11:16:01 EDT 2008

On Oct 27, 2008, at 12:53 PM, chen li wrote:

> I am new to FxRuby. I am learning it by studying some code samples.  
> Now I am confused about a method call in the following script:   
> which class  defines method  create, class FXApp or HelloWindow/ 
> FXMainWindow?

Both FXApp and FXMainWindow define create() methods. In your example  
program, your HelloWindow class is overriding the base class version  
of create() defined in FXMainWindow. You also call the FXApp object's  
create() method later.

> Based on the code, class HelloWindow/FXMainWindow defines method  
> 'create'. If this is true , the object from this class can response  
> to the message. But here why does an object created by a different  
> class FXApp response to method 'create'?

Calling create() on the FXApp in turn leads to calls to create() on  
all of the application windows, including your HelloWindow instance.

Hope this helps,


"FXRuby: Create Lean and Mean GUIs with Ruby"
Now available from the Pragmatic Bookshelf!

More information about the fxruby-users mailing list