开发者

How do you printf and sprintf in Io?

开发者 https://www.devze.com 2023-04-11 16:16 出处:网络
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, ...)?

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

精彩评论

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