Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种简洁的方法来做到这一点?
情况1
File.open(infile, 'r').readlines.each do |line| process end
案例2
ARGF.readlines.each do |line| process end
这是你要找的吗?
method = something_to_help_me_decide ? File.open(infile, 'r') : ARGF method.readlines.each do |line| process end
不太清楚你在这里做什么。