Throughout this book, we use the following typographic notations.
Literal code examples are shown using a typewriter-like font:
class SampleCode
def run
#...
end
end
|
Within the text,
Fred#doIt
is a reference to an instance method
(
doIt
) of class
Fred
, while
Fred.new
[In
some other Ruby documentation, you may see class methods written as
Fred::new
. This is perfectly valid Ruby syntax; we just happen
to feel that Fred.new
is less distracting to read.] is a class
method, and
Fred::EOF
is a class constant.
The book contains many snippets of Ruby code. Where possible, we've
tried to show what happens when they run. In simple cases, we show the
value of expressions on the same line as the expression. For example:
At times, we're also interested in the values of assignment statements,
in which case we'll show them.
a = 1
|
� |
1
|
b = 2
|
� |
2
|
a + b
|
� |
3
|
If the program produces more complex output, we show it below the
program code:
3.times { puts "Hello!" }
|
produces:
In some of the library documentation, we wanted to show where spaces
appear in the output. You'll see these spaces as ``
'' characters.
Command-line invocations are shown with literal text in a Roman font,
and parameters you supply in an
italic font.
Optional elements are shown in large square brackets.
ruby [
flags
]*
[
progname
] [
arguments
]+
|