From: "David A. Black" Date: 2007-10-28T23:49:11+09:00 Subject: Re: Fluent programming in Ruby Hi -- On Sun, 28 Oct 2007, Paul Brannan wrote: > On Fri, Oct 26, 2007 at 02:01:17PM +0900, David Flanagan wrote: >> With this change, code like this works: >> >> puts "hello" >> .upcase >> .reverse >> .slice(0) # => prints "O" > > Hmm, will this work with other binary operators too? > > str = "This" > + " is a" > + " test" > > verses how this is currently done: > > str = "This" \ > + " is a " \ > + " test" How about: 1 .2 :-) I suspect it's only for the dot. I don't know how it would handle, for example: def meth(x) puts x -1 end > BTW, some people don't seem to like the fluent method chaning, but it's > not terribly different from using the backslash: > > puts str \ > .upcase > > except that the backslash works correctly in irb. I think it's radically different, because the backslash is contained in the first line -- so the fact that the line is continuing is already denoted. David -- Upcoming training by David A. Black/Ruby Power and Light, LLC: * Advancing With Rails, Edison, NJ, November 6-9 * Advancing With Rails, Berlin, Germany, November 19-22 * Intro to Rails, London, UK, December 3-6 (by Skills Matter) See http://www.rubypal.com for details!