3 ms·
Show HN: Two line ruby quine
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
- deleted 15y ago[deleted]
- AndrewVos 15y agoI think the use of eval is thought of as cheating. Also I seem to remember writing to files is also cheating?
- madamepsychosis 15y agonot 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