From: Felipe Navas Date: 2007-01-10T14:01:24+09:00 Subject: Re: [ANN] Elements of Ruby Style Maybe some example... would be nice ;) On 1/10/07, Jeremy McAnally wrote: > > > > It's the same calling semantics. The advantage when writing code is > > really just that code which uses yield is faster and looks better than > > code that explicitly calls the block. > > > > Ack! You guys are right. Senior moment (actually, it was a I stayed > up til 3:30am writing and then worked all day moment...but same effect > ;)). That was one that I had picked up from another page or ML post; > I'm sure I had reasons but now that I look at it it doesn't make > sense. My mistake! > > > > > I think it's a good idea to discuss the reasons, here. > > > > Sometimes, + is what you want. When dealing with strings, + will give you > > a new String. If you just want to combine two things, though, << is often > > your best bet because it simply modifies the string it is called on > > instead of creating a new String, and > > > > a << b > > > > looks a lot better than > > > > "#{a}#{b}" > > > > Right, that's why I said literals. When I combine two string objects, > I usually use + just because semantically it makes more sense, but > when there's a string literal involved, I usually use interpolation. > I think this is a preference thing, but I always thought that was > general practice. Please do correct me if I'm wrong. > > --Jeremy > > -- > My free Ruby e-book: > http://www.humblelittlerubybook.com/book/ > > My blogs: > http://www.mrneighborly.com/ > http://www.rubyinpractice.com/ > > -- (.) CAMPANHA DA FITA ASCII ( http://arc.pasp.de/) / \ Contra formatos proprietarios