From: Phillip Gawlowski Date: 2010-01-10T05:15:04+09:00 Subject: Re: Ruby editing style rules and recommendation? On 09.01.2010 21:01, Nathan Oyama wrote: > I asked a question 'Decimal in for loop?' and two members were kind > enough to solve this problem. Thanks, Fleck and Aaron. > > Now I have another question: Are there any editing style rules and > recommendations in Ruby? > > In the previous thread, Fleck wrote: > > 0.step(0.5,0.1) { |i| p i } > > while Aaron wrote: > > (0..0.5).step(0.1) do |f| > p f > end > > and both work identically. > > Which one is recommended in terms of the editing style? Whatever fits the situation. No, really. If the {...} block form fits in an instance, you use that. If the do...end block form fits, you use that instead. Caveat: The latter is most common if you deal with a multi-line block: a_block do |x| puts x x += 1 end Otherwise: Indents are two spaces. Not tabstops of length 2, but the actual character (" "). And once you have written enough Ruby, you'll know what "feels" correct to you. -- Phillip Gawlowski