Matz has just checked a change into the Ruby 1.9 tree to allow programming with fluent interfaces. The change is marked "experimental", but if it stays in the tree, we'll be able to write Ruby code like this:
puts "hello"
.upcase
.reverse
.slice(0) # => Prints "O"
(This is a silly example; Martin Fowler's page linked above has more compelling examples of this style of method chaining.)
We've always been able to do method chaining in Ruby, of course. What Matz's patch does is allow newlines in between the methods. This is tricky in languages like Ruby that don't require semicolons because newlines usually act as the statement terminators. So with this new modification a newline does not terminate a statement if the first non-space character on the following line is a period.
P.S. In case it hasn't been obvious from my recent postings on Ruby, I'm writing a book about Ruby. And I'm nearly done!



