Sean Warburton wrote:
> Hello Burke, thanks for the reply, I used the word file but I don't 
> actually build a file, sorry. What i should have said is that I want to 
> build an array of five XML requests , populating each request with the 
> data from an existing array of five items that will be passed as an 
> argument. Does that sound clearer and make more sense?

# This converts a single item into its XML request
def process(input)
  "The answer is #{input}"
end

source = ["foo", "bar", "baz"]

# Option 1: build another array

dest = source.map { |doc| process(doc) }
puts dest[0]

# Option 2: build a Hash

dest = {}
source.each { |doc| dest[doc] = process(doc) }
puts dest["foo"]
-- 
Posted via http://www.ruby-forum.com/.