🕷 zenspider.com

by ryan davis



sitemap
Looking for the Ruby Quickref?

ruby quine _slightly_ smaller than python quine

Published 2006-09-04 @ 01:31

Tagged toys, ruby

I found Shortest Python Quine? (was miscoranda.com, now some sort of archived page) and thought I’d check it out. I wasn’t aware of python’s %r, but apparently it is equivalent to our %p (which I always forget about). Anyhow, here is our version:

% ruby quine.rb 
_="_=%p;puts _%%_";puts _%_
% ruby quine.rb | ruby
_="_=%p;puts _%%_";puts _%_

or eric’s morph:

% echo '_="_=%p;puts _%%_";puts _%_' | ruby | ruby
_="_=%p;puts _%%_";puts _%_

Comes in at 28 characters, and ties the shortest on (the now defunct) rubygarden wiki.