From: jjenning@... (jared l. jennings) Date: 2001-07-27T03:27:16+09:00 Subject: [ruby-talk:18586] Re: My first Ruby program... :-) On Fri, Jul 27, 2001 at 02:52:05AM +0900, Bjorn Pettersen wrote: > Well, it's now two days into playing with Ruby, and I wrote my first > non-trivial program (it's converting a large c++ enum to constants). I'm > still shaky on idiomatic usage, so if any of the initiated would care to > comment on coding style I would be very grateful. Looks good... see bottom for my only suggestion > class StringTable ] ... > > def output ] ... > @table.each {|row| > printf(fmt, *row) > } > end > end > > def test ] ... > st.output > end > > test if you defined a #to_s method instead of #output and made it build up and return a string instead of printf'ing straight to the output, then you could go print st It's more idiomatic, and it affords you the ability to print the table to any stream (e.g., myOutFile.print st) hth -- Doubt is a pain too lonely to know that faith is his twin brother. - Kahlil Gibran