<html> <head> <title>Ruby FAQ: Undocumented Features </title> </head> <body> <a href="rubyfaq-8.html">Previous</a> Next <a href="rubyfaq.html#toc9">Table of contents</a> <hr> <h2><a name="s9">9. Undocumented Features </a></h2> <h2><a name="ss9.1">9.1 What does <code>a ? b : c</code> mean? </a></h2> It means <code>if a then b else c end</code>. <h2><a name="ss9.2">9.2 How can I count the number of lines in a file? </a></h2> Assuming that the file ends in a linefeed, following code may give the fastest result. <code>open("file").read.count("\n")</code> <h2><a name="ss9.3">9.3 What do <code>begin</code> and <code>end</code> of MatchingData return? </a></h2> They act with $~, and return the start index and the end index of matched data $0, $1... in the original string. See an example in <a href="rubyfaq-7.html#tab">tab expansion</a>. <hr> <a href="rubyfaq-8.html">Previous</a> Next <a href="rubyfaq.html#toc9">Table of contents</a> </body> <html>