The Ruby on Rails and ClojureScript experts

Jan 14, 2013

DATAis in fact an IO object, that you can read from (or anything else you’d do with an IO object). It contains all the content after__END__in that ruby script file*. (It only exists when the file contains__END__, and for the first file ruby invokes though. Seefootnotefor more details.)

How can we use this, and why indeed do I love this fickle constant? I mostly use it for quick scripts where I need to process text data, rather than piping to STDIN.

An example:
DATA.each_line.map(&:chomp).each do |url| `open "#{url}"` end __END__ http://google.com/ http://yahoo.com/

Link: Why I love DATA – Caius Theory via caiustheory.com