From: Robert Dober Date: 2006-07-15T00:44:05+09:00 Subject: Re: A newbie would like some code criticism, please... ------=_Part_25003_17505401.1152891840914 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 7/7/06, Jeff Pritchard wrote: > > Everybody else seems to be focusing on your "first, rest" question. You > also asked about general coding style and correctness... > > I'm a newbie too, so take this with a grain of salt unless one of the > senior members agrees with me. The thing I found most notable about > your code overall was the use of { } for multi-line blocks. This is > certainly legal, but I think it is considered poor form, as I don't ever > see it in ruby code listed here or in books. As I understand it, the > preferred way is to use {} for blocks that are all on one line, and do - > end pair for multi-line blocks. Honestly I do not think so, personally I prefer do..end to {..} unless {..} looks prettier. I too see a tendency to use {} on short blocks but would not go so far to say that e.g. File.open(__FILE__)' { |f| f.each { ... } } is bad or even uncommon practice. The liberty to use do...end or {} is given on purpose. Cheers Robert best, > jp > > > Just Another Victim of the Ambient Morality wrote: > > I'm learning Ruby and I'd like some criticism on a program that I wrote= . > > It interfaces with iTunes and runs through all the songs, (reasonably) > > ensuring proper title capitalization. It's a small program and I would > > have > > simply posted except that, for some unknown reason, MS Outlook Express > > keeps > > converting the tabs into single spaces. > > I'm open to comments on style versus what is standard protocol for > > the > > Ruby community, as well. > > I hope the program may be as useful to any of you as it is for me..= . > > > > http://theorem.ca/~dlkong/iTunes_title_filter.rb.gz > > > > > > There's also a pattern that often comes up for me and I would like > > some > > help with it... > > > > first =3D true > > list.each do |item| > > if first > > # do something special for the first case > > > > first =3D false > > else > > # do something else for every other item > > end > > end > > > > Is there a better way to do this? Perhaps some way to simply > > iterate > > over every element other than the first one? Something that avoid a > > check > > every iteration? > > > > Thank you... > > > -- > Posted via http://www.ruby-forum.com/. > > --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_25003_17505401.1152891840914--