Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Correctly narrow sprintf's claimed abilities


The sprintf() operator can be applied to either a number or a string. The operator takes a formatting string as its sole argument. The formatting string follows the conventions for sprintf() established in other languages. Specifically, the KRL version of sprintf() follows the formatting conventions for Perl. For example Currently, the formatting string for strings supports %s and does not support escaping a literal %s:

Code Block
a = 10
c "Hello world!"
b = a.sprintf("< %s %d>>") // cb = "< Hello world! 10>>"


The substr() operator returns a substring of the target string. The operator takes an argument that gives an offset from the start of the string to begin returning the substring and an optional length that gives the desired length of the substring. If the length is omitted, the substring to the end of the original string from the offset will be returned. If the length is negative, the length will be caluclated from the end of the string. For example: