2010-04-13 6 views

Répondre

4

Oui.

irb(main):007:0> arg1 = 'foo' 
=> "foo" 
irb(main):008:0> arg2 = 'bar' 
=> "bar" 
irb(main):009:0> sprintf("%3$0.3f this is %2$s test %1$s" , arg1, arg2, Math::PI) 
=> "3.142 this is bar test foo" 

Le format est %N$fmt où N indique la position ordinale de l'argument, et fmt est ce que vous mettriez après le signe % lors de l'utilisation sprintf normalement.