Ruby 多行书写的字符串,如何在输出时不换行

kitaro000 · September 28, 2015 · Last by kitaro000 replied at September 28, 2015 · 3959 hits

比如

%Q(
  a
  b
  c
)

输出时是“abc”

s=%Q(a\
b\
c\
d)
print s

#1 楼 @africwildman 谢谢,不过虽然是单行显示,中间会有空格,这个怎么办?

%Q( a b c ).gsub(/\s+/,'')

You need to Sign in before reply, if you don't have an account, please Sign up first.