From: Josh Cheek on 11 Jan 2010 07:51 [Note: parts of this message were removed to make it a legal post.] On Mon, Jan 11, 2010 at 12:49 AM, Albert Schlef <albertschlef(a)gmail.com>wrote: > Why? > > It makes it conspicuous where everything begins and ends, you don't have to analyze anything to figure it out. > How would you usually add one level of nesting there? (perhaps I could > learn an editing trick.) > > I don't think I understand the question, you write it the same way you normally would, you just replace some do/end with brackets, where they make it easier to follow. The criteria are subjective. I'm not sure what you mean by an editing trick, presumably you're thinking as Marnen did, that adding a level obligates me to swap anything back and forth. I don't consider that to be the case, it's not a rule, it's just something I do to clarify my code, sometimes I find two do/end pairs between every bracket is easiest to read, it just depends. But if you're in TextMate, you can do ctrl+{ to swap back and forth. It seems to work okay, but is a little buggy, so I don't use it often.
From: Lars Christensen on 13 Jan 2010 07:30 On Sat, Jan 9, 2010 at 9:01 PM, Nathan Oyama <nate(a)culip.net> wrote: > 0.step(0.5,0.1) { |i| p i } > > while Aaron wrote: > > (0..0.5).step(0.1) do |f| > p f > end > > Which one is recommended in terms of the editing style? Whichever makes the code more readable in each situation. I tend to use braces/{ } in functional-style code and do/end in imperative-style code. For example, I usually use braces with Enumerable#map/select/delete_if/find/sort, and do/end with Enumerable#each, File#open and Thread#new.
First
|
Prev
|
Pages: 1 2 3 Prev: What does "w+" mean in IO.open ? Next: Confusing docs . . . how do I use gcd2? |