Tk methods return value

Hi,

I am starting learning Ruby/Tk ( may-be later write a tutorial ).
I have a question about Ruby/Tk library implementation.
Why the methods like setting background, foreground, text, … etc
just return an empty string instead of ‘self’ ?

For example:
b = TkButton.new
b.text # ==> without argument, this will return the text
# this is same as b[‘text’] or b.cget(‘text’).

now

b.text( ‘Hello World’) # ==> this returns a empty string, for me it is really useless.

If bg, fg, text … etc like pack can return ‘self’ we could write code like:

b = TkButton.new.pack.bg(‘red’).fg(‘black’).text(‘Hello’)
I know, we could write it like
b = TkButton.new(‘bg’=>‘red’, ‘fg’=>‘black’, ‘text’=>‘Hello’).pack
or
b = TkButton.new { bg ‘red’; fg ‘black’; text ‘Hello’ }.pack # or put pack insdie { }

I just thought return empty string is really useless; so why not return ‘self’ then we could have other way to write the code ( and make it shorter )

I know we could use ‘configure’ to combine

Is there any raison returns empty string ( or in same situation returns other things) ?

Thanks,
Dave

···

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Hi,

···

From: D T tran55555@yahoo.com
Subject: Tk methods return value
Date: Tue, 17 Jun 2003 05:26:09 +0900
Message-ID: 20030616202607.34282.qmail@web40608.mail.yahoo.com

Why the methods like setting background, foreground, text, … etc
just return an empty string instead of ‘self’ ?

Now I’m working on Ruby/Tk for Ruby-1.8.
The problem is fixed at Thu, 12 Jun 2003 21:14:11 +0000.
Please check the CVS head.
However, I’ll commit new patch in a few days.

                              Hidetoshi Nagai (nagai@ai.kyutech.ac.jp)

Cool. That makes more sense to me.
Thanks.

···

Hidetoshi NAGAI nagai@ai.kyutech.ac.jp wrote:

Now I’m working on Ruby/Tk for Ruby-1.8.
The problem is fixed at Thu, 12 Jun 2003 21:14:11 +0000.
Please check the CVS head.
However, I’ll commit new patch in a few days.

Hidetoshi Nagai (nagai@ai.kyutech.ac.jp)


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!