Re: Fruit basket program in Ruby.NET

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sat, 5 Jan 2008 10:40:39 -0500 (EST)

I wish Ruby let one specify properties of an object when it is created,
like Python, Boo, or C# 3.0.  I've heard such syntax is being considered
for a future version.

I wanted to see how close I could get using current features of the Ruby
language.  I found that a single property could be set using syntax like
the following:

(btnAdd = Button.new).Text = "&Add"

Multiple properties could be set using a hash and the eval method with
syntax like the following:

tlp = TableLayoutPanel.new
{"ColumnCount" => 3, "RowCount" => 2}.each_pair {|property, value|
eval("tlp.#{property} = #{value}")}

Readability is definately sacrificed in the latter case, so the lines of
code saved may not be worth it!

Jamal

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: