Quine: Difference between revisions
Ruby: improve wording and formatting; Rust: improve formatting
(Ruby: delete the more verbose file-reading example, as the next example is equivalent and simpler) |
(Ruby: improve wording and formatting; Rust: improve formatting) |
||
Line 3,495:
=={{header|Ruby}}==
Found online:
<lang ruby>_="_=%p;puts _%%_";puts _%_</lang>
A shell session demonstrating that it is valid:
<pre>$ ruby -e '_="_=%p;puts _%%_";puts _%_'
_="_=%p;puts _%%_";puts _%_
Line 3,500 ⟶ 3,503:
_="_=%p;puts _%%_";puts _%_</pre>
A more readable version of the above example:
<lang ruby>x = "x = %p; puts x %% x"; puts x % x</lang>
The <
<lang ruby>puts <<e*2,'e'
puts <<e*2,'e'
e</lang>
<lang ruby>eval s="puts'eval s='+s.inspect"</lang>
Line 3,531 ⟶ 3,534:
Using the method on Wikipedia (0.9-pre-compatible, does not compile on Rust 1.0.0 and newer):
<lang rust>fn main()
{
let q = 34u8;
Line 3,590 ⟶ 3,592:
i+=1;
}
}</lang>▼
▲</lang>
A quine in the shape of a circle:
|