1

According to this site, $< is under Predefined variables and it says # See ARGF.

I have seen a code like $<.map{|x|n,m=x.split.map(&:to_i);... and using it with command line input.

I googled it but I am not able to find an explanation or how to use it.

How does it differ from $_?

halfer
  • 19,824
  • 17
  • 99
  • 186
shin
  • 31,901
  • 69
  • 184
  • 271
  • This should help Its standard input http://stackoverflow.com/questions/4279604/what-is-the-difference-between-stdin-and-stdin-in-ruby All the built-in ruby methods use $< (a.k.a. ARGF) to read input. If ARGV is empty, ARGF reads from $stdin, so if you reassign $stdin, that will affect all built-in methods. If you reassign STDIN it will have no effect unless some 3rd party method uses STDIN. – Abs May 27 '14 at 06:37
  • Apidock explains ARGF quite well: http://apidock.com/ruby/ARGF – Sven Koschnicke May 27 '14 at 06:40

1 Answers1

1

If you look at ARGF on that page you'll see;

ARGF              # A meta-IO across all files in ARGV. (eg ARGF.each_line...)

So you should try $<.each_line

Koen.
  • 25,449
  • 7
  • 83
  • 78