Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




Ruby Programming
Previous Page Home Next Page

Source Layout

Ruby programs are written in 7-bit ASCII.[Ruby also has extensive support for Kanji, using the EUC, SJIS, or UTF-8 coding system. If a code set other than 7-bit ASCII is used, the KCODE option must be set appropriately, as shown on page 137.]

Ruby is a line-oriented language. Ruby expressions and statements are terminated at the end of a line unless the statement is obviously incomplete---for example if the last token on a line is an operator or comma. A semicolon can be used to separate multiple expressions on a line. You can also put a backslash at the end of a line to continue it onto the next. Comments start with `#' and run to the end of the physical line. Comments are ignored during compilation.

a = 1

b = 2; c = 3

d = 4 + 5 +      # no '\' needed     6 + 7

e = 8 + 9   \     + 10         # '\' needed

Physical lines between a line starting with =begin and{[email protected]{=begin documentation} a line starting with =end are ignored by the compiler and may be used for embedded documentation (see Appendix A, which begins on page 511).

Ruby reads its program input in a single pass, so you can pipe programs to the compiler's stdin.

echo 'print "Hello\n"' | ruby

If the compiler comes across a line anywhere in the source containing just ``__END__'', with no leading or trailing whitespace, it treats that line as the end of the program---any subsequent lines will not be compiled. However, these lines can be read into the running program using the global IO object DATA, described on page 217.
Ruby Programming
Previous Page Home Next Page

  Published under the terms of the Open Publication License Design by Interspire