rubyist.net网站实例学习

字符串:

ruby> "\n"
  "\n"    # 即换行
ruby> '\n'
  "\\n"   # 不是换行
ruby> "abcd #{5*3} efg"
  "abcd 15 efg"
ruby> var = " abc "
  " abc "
ruby> "1234#{var}5678"
  "1234 abc 5678"



ruby> "foo" + "bar"
  "foobar"
ruby> "foo" * 2
  "foofoo"

puts "Hello #{name}!"     #字符串中设置变量