Thread: Ruby Snippets
View Single Post
Old Apr 14th, 2006, 9:53 AM   #20
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Unhappy

Any wxPython (GUI) code in general uses a lot of named arguments. If Ruby does not have named arguments, then that explains why wxRuby code looks sooo different!

I looked at a hash as a workaround, but that has real problems too! It doesn't use the given default values.

# using a dictionary/hash container, still problems
def funk2(hash1 = {:a => 2, :b => 3}) 
  print "a=#{hash1[:a]}  b=#{hash1[:b]}\n" 
end 

funk2()     # a=2  b=3
funk2(:a=>1)  # a=1  b=  b should be 3 
funk2(:b=>1)  # a=  b=1  a should be 2 
funk2(:a=>12, :b=>13)  # a=12  b=13
Does anybody know how to do this right in Ruby, before the code looks alltogether too homely?
__________________
I looked it up on the Intergnats!

Last edited by Dietrich; Apr 14th, 2006 at 10:07 AM.
Dietrich is offline   Reply With Quote