On Fri, 06 Jun 2003 22:13:30 +0200, Simon Strandgaard wrote:
> 
> Sorry I was too quick... you need to do "collect & join", like this:
> 
>     @cgi.tr { row.collect { |cell| @cgi.td {"#{cell}"} }.join }
> 

If you think that "collect & join" is anoying.. then try this:


class Array
	# block-join
	def bjoin(sep=$,)
		return join(sep) if not block_given?
		collect { |y| yield(y) }.join(sep)
	end
end

#puts [1, 2, 3].bjoin
#puts [1, 2, 3].bjoin("-")
#puts [1, 2, 3].bjoin { |v| "<td>#{v-1}</td>" }
#puts [1, 2, 3].bjoin(" ") { |v| "<td>#{v-1}</td>" } 


It enables you to do like this:

    @cgi.tr { row.bjoin { |cell| @cgi.td {"#{cell}"} } }


OK.. I don't think I have anymore spam for today :-)

--
Simon Strandgaard