开发者

How do you printf and sprintf in Io?

How can I:

  • convert an object to a string without printing it, a la Python's str(obj)?
  • print using percent (%) directives a la C's printf(format, obj1, obj2, ...)?
  • create a string using percent (%) directive开发者_运维问答s without printing to stdout a la C's sprintf(str, fmt, obj1, obj2, ...)?


Interpolation:

"2 + 2 = #{4}" interpolate

Concatenation:

"2 + 2 = " .. 4 asString

Interpolation with printing:

"2 + 2 = #{4}" interpolate println

Concatenation with printing:

("2 + 2 = " .. 4 asString) println
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜