【发布时间】:2013-01-08 14:11:02
【问题描述】:
我正在构建一个 gem,它将一个特定的字符串附加到每个 puts 输出。用例可能如下所示:
string_to_append = " hello world!"
puts "The web server is running on port 80"
# => The web server is running on port 80 hello world!
我不知道该怎么做。它的伪代码可能是这样的:
class GemName
def append
until 2 < 1
if puts_is_used == true
puts string << "hello world!"
else
puts ""
end
end
end
end
非常感谢任何有关如何做到这一点的最佳方法的见解。
【问题讨论】:
标签: ruby concatenation puts