J
Joe Laughlin
I have an array that looks like this:
my_array = [["Jane", "Smith"], ["Bob", "Jones", 1960]]
I want to copy each element of my_array into a another object (in this case,
a Gtk::TreeIter).
I'm currently doing something like this:
tree_store = Gtk::TreeStore.new(String, String, Integer)
my_array.each do |person|
count = 0
row = tree_store.append(nil)
person.each do |attribute|
row[count] = attrib
count = count + 1
end
end
So, for each attribute that's in my_array, I want to copy it into the
appropriate row element.
This works, but how can I do it more cleanly, or more in the ruby spirit?
Thanks,
Joe
my_array = [["Jane", "Smith"], ["Bob", "Jones", 1960]]
I want to copy each element of my_array into a another object (in this case,
a Gtk::TreeIter).
I'm currently doing something like this:
tree_store = Gtk::TreeStore.new(String, String, Integer)
my_array.each do |person|
count = 0
row = tree_store.append(nil)
person.each do |attribute|
row[count] = attrib
count = count + 1
end
end
So, for each attribute that's in my_array, I want to copy it into the
appropriate row element.
This works, but how can I do it more cleanly, or more in the ruby spirit?
Thanks,
Joe