ruby basic

basic

!と?について

  • !がつくメソッドは破壊的メソッド。呼び出しによってオブジェクト元を破壊する
  • ?がつくメソッドは真偽値を返す

例外処理

begin
  # some process
rescue Exception => ex
  puts ex.message
end

ファイルを1行ずつ読み込む

begin
  File.open('dialog/feature.txt') do |file|
    file.each_line do |row|
      puts row
    end
  end
rescue Exception => ex
  puts ex.message
end

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.