On Oct 22, 1:35 pm, Morton Goldberg <m_goldb... / ameritech.net> wrote:
> On Oct 21, 2007, at 10:25 PM, Frank J. Lhota wrote:
>
> > Dear Ruby fans,
>
> > A common Lisp exercise is to write a Lisp program that writes its own
> > source code to standard output. Reading from a source file is not
> > permitted.
>
> > This leads one to wonder: what is the smallest and / or most elegant
> > Ruby program that writes its own source code to standard output? As
> > with Lisp, reading from a file is not permitted. Given the nature of
> > the language, this problem should  should have a lot of interesting
> > solutions.
>
> My favorite Ruby quine is
>
> <code>
> DATA.rewind
> STDOUT.write(DATA.read)
> __END__
> </code>

Very nice. I looked up "DATA" in the pickaxe and found that I had
previously highlighted it - must've been a long time ago. Here's a
rewindless version :)

puts DATA.read * 2
__END__
puts DATA.read * 2
__END__