【发布时间】:2011-01-13 02:07:59
【问题描述】:
我有一些固定宽度的大文件,我需要删除标题行。
跟踪迭代器似乎不太习惯。
# This is what I do now.
File.open(filename).each_line.with_index do |line, idx|
if idx > 0
...
end
end
# This is what I want to do but I don't need drop(1) to slurp
# the file into an array.
File.open(filename).drop(1).each_line do { |line| ... }
Ruby 的成语是什么?
【问题讨论】:
标签: ruby enumerable