From: Peter Szinek Date: 2006-10-20T05:04:27+09:00 Subject: Re: How to format an array Hello, Li Chen wrote: > Hi all, > > I have an array [1.0, 2.0, 3, 4,5,6]. I want to format all the elements > within the array into to this format "%5.3f", that is 5 > spaces/characters for each number/element, followed by 3 floating > points. Any help will be appreciate. [1.0, 2.0, 3, 4,5,6].map { |n| sprintf "%5.3f", n } Peter http://www.rubyrailways.com