-1

Is there a concise way to do it?

case 1

File.open(infile, 'r').readlines.each do |line|
  process
end

case 2

ARGF.readlines.each do |line|
  process
end
user3477465
  • 183
  • 2
  • 2
  • 6

1 Answers1

1

Is this what you're looking for?

method = something_to_help_me_decide ? File.open(infile, 'r') : ARGF
method.readlines.each do |line|
  process
end

Not super clear what you're going for here.

Nick Veys
  • 23,458
  • 4
  • 47
  • 64