From: nobu.nokada@... Date: 2001-12-11T04:05:07+09:00 Subject: [ruby-talk:28126] Re: Handling parameters differently? At Tue, 11 Dec 2001 03:40:06 +0900, Tim Christian wrote: > printf("test 1: %2.2f%% End of test 1\n", 1.4) > printf "test 2: %2.2f%% End of test 2\n" % [1.4] > > I would assume the second statement would work just like the first, > but it doesn't. The above code frag displays: > > test 1: 1.40% End of test 1 > t.rb:5:in `printf': too few argument. (ArgumentError) > from t.rb:5 > > I haven't figured out how to embed a percent sign in the format string > using the second statement format style (which I prefer). Any ideas? printf "test 2: %2.2f%%%% End of test 2\n" % [1.4] Since String#% and also printf interprets percent signs, you need to escape twice. Or use print instead of printf. print "test 2: %2.2f%% End of test 2\n" % [1.4] Nobu Nakada