Ruby > 標準出力

更新日 2013-12-20
広告
文字列を出力する方法を紹介します。

print

print メソッドは文字列を引数に取ります。
  print "test\n"
変数を埋め込む場合は、#{変数} とします。
  count = 5
  print "test #{count}\n"

puts

putsも、printと同様に、文字列を出力します。ただし、putsは自動的に改行を行います。
  puts "test"
広告
お問い合わせは sweng.tips@gmail.com まで。
inserted by FC2 system