From: cedlemo <ce...@gm...> - 2016-11-09 10:58:02
|
We could use this trick irb(main):001:0> def myfn(*args) irb(main):002:1> puts args.size irb(main):003:1> end => :myfn irb(main):004:0> myfn("arg1","arg2","arg3") 3 => nil irb(main):005:0> myfn(:arg1 => "arg1", :arg2 => "arg3") 1 => nil If args size is equal to one then you use your code else you use the previous code. This way allows us to implement the has form while we keep the compatibility with the previous code. We have done done this already in some of the ruby-gnome class but Kou would offer you a better answer than me. cedlemo On 08/11/2016 19:43, Detlef Wagner wrote: > Hi, > > to the C function gtk_tree_view_column_new_with_area is no ruby > equivalent. I think, it is most useful to use an options hash for > initialize, like this: > > def initialize(options={}) > area = options[:area] > renderer = options[:renderer] > title = options[:title] > attributes = options[:attributes] || {} > > if area > initialize_new_with_area(area) > else > initialize_raw > end > set_title(title) if title > pack_start(renderer, true) if renderer > attributes.each_entry do |key, value| > add_attribute(cell, key, value) > end > end > > > But this would not be backward compatible. Any suggestions or opinions? > > Cheers, detlef > > ------------------------------------------------------------------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today. http://sdm.link/xeonphi > _______________________________________________ > ruby-gnome2-devel-en mailing list > rub...@li... > https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en |