From: D T Date: 2003-06-17T05:26:09+09:00 Subject: Tk methods return value --0-1454417893-1055795167=:33822 Content-Type: text/plain; charset=us-ascii 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! --0-1454417893-1055795167=:33822 Content-Type: text/html; charset=us-ascii
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! --0-1454417893-1055795167=:33822--