Change to sprintf function

M

mark

While testing the Log4r module I've discovered that the sprintf function has
changed in 1.8.

Using the following test script

#!/usr/bin/ruby -w

puts sprintf("%*3$s %s", "abcd", "abcd", 10)

I get

[mark@laptop log4r-1.0.2]$ ruby1.6 -v test.rb
ruby 1.6.7 (2002-03-01) [i586-linux-gnu]
abcd abcd

[mark@laptop log4r-1.0.2]$ ruby -v test.rb
ruby 1.8.0 (2003-08-04) [i686-linux]
test.rb:3:in `sprintf': unnumbered(1) mixed with numbered (ArgumentError)
from test.rb:3

Does anyone know the correct way to call sprintf under 1.8? I've looked at the
ruby-lang site to see if this change is mentioned but that just lists the new
&p modifier.

Thanks in advance

Best Regards

Mark Sparshatt
 
B

Brian Candler

While testing the Log4r module I've discovered that the sprintf function has
changed in 1.8. ...
[mark@laptop log4r-1.0.2]$ ruby -v test.rb
ruby 1.8.0 (2003-08-04) [i686-linux]
test.rb:3:in `sprintf': unnumbered(1) mixed with numbered (ArgumentError)
from test.rb:3

Does anyone know the correct way to call sprintf under 1.8? I've looked at the
ruby-lang site to see if this change is mentioned but that just lists the new
&p modifier.

It was discussed on this list a few days ago. See http://ruby-talk.org/

(Note: the search engine is deceptive. Ignore the message about the archive
containing 0 documents / 0 documents matched your search, and just scroll
down to the results)

Regards,

Brian.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,121
Messages
2,570,712
Members
47,282
Latest member
hopkins1988

Latest Threads

Top