From: Jon Aseltine Date: 2000-09-03T21:22:09+09:00 Subject: [ruby-talk:4760] Re: Piping in Ruby? list.scan(pattern).collect{|i| convert(i)}.each{|i| code} Stephen White wrote: > > On Sat, 2 Sep 2000, Dave Thomas wrote: > > > > I've had a brief look through Ruby's syntax, and it appears that > > > it's possible to assign different inputs and outputs, but nothing as > > > quick and easy as the '|' convention used in shells. > > > > Could you give an example of how you'd use this in Ruby? > > Currently, I keep repeating this construct: > > a = [] > list.scan(pattern) {|i| a << convert(i) } > a.each {|i| code } > > whereas I'd like to do: > > list.scan(pattern) {|i| convert(i) } | each {|i| code } > > instead. Eg, I don't need the intermediate 'a' array. > > Thanks. :) > > -- > steve@deaf.org -- _______________________________________________________________________ Jonathan Aseltine aseltine@cs.umass.edu MAS, Umass, Amherst