るりまサーチ (Ruby 3.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.060秒)
トップページ > クエリ:ruby[x] > クエリ:string[x] > クエリ:String[x] > クエリ:$[x] > 種類:特異メソッド[x] > クラス:IO[x] > バージョン:3.0[x]

別のキーワード

  1. string []=
  2. string slice!
  3. string slice
  4. string []
  5. openssl ia5string

ライブラリ

検索結果

IO.readlines(path, rs = $/, chomp: false, opts={}) -> [String] (961.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...emlist[例][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO
.write("testfile",...
..."line1,\rline2,\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...