0

Coming from the Java world, I am reassured to see in the docs that there is formatting support for numbered parameters, so that if I have the following string format:

String(format:"%1$s drew from the %3$s pile and discarded the %4$s", name, pickedUp, pile, discard)

I would expect: Droid drew from the Draw pile and discarded the KS (ignoring the second parameter which is the picked up card)

But what I actually get is: Droid drew from the 5C and discarded the Draw

as if it totally ignored the numbered parameters. What am I doing wrong?

Opus1217
  • 723
  • 4
  • 17
  • From the accepted answer to the "duplicate": *"When numbered argument specifications are used, specifying the Nth argument requires that all the leading arguments, from the first to the (N-1)th, are specified in the format string."* – If you omit the 2nd argument in the format string then the behaviour is undefined. – Martin R Jan 01 '16 at 17:45
  • Thanks - this answer didn't pop up when I was about to submit. Completely answers my question. – Opus1217 Jan 01 '16 at 18:49

0 Answers0