Show HN: Two line ruby quine

6 points by madamepsychosis ↗ HN
Thought you might like this. This Ruby program makes an exact copy of itself.

c = "File.open('new.rb', 'w') {|f| f.write('c = ' + c.inspect + '\neval c') }"

eval c

3 comments

[ 2.3 ms ] story [ 3.5 ms ] thread
(comment deleted)
I think the use of eval is thought of as cheating. Also I seem to remember writing to files is also cheating?
not sure about fixing the eval part, but reading the source code is usually thought of as cheating. However, that's not what this is doing. It could easily be changed to:

c = "puts('c = ' + c.inspect + '\neval c')" eval c