Appendix A. A brief introduction to Ruby
In this appendix, we provide a brief overview of the basics of the Ruby language.
Ruby programs and scripts are simple text files that have the filename extension .rb. To execute a Ruby program, you simply type
ruby file_name.rb
where file_name represents the name of the Ruby file you wish to run.
Ruby is an imperative language, and as such, a program file consists of a set of linear command invocations similar to C, C++, Perl, or Java. The Hello World application in Ruby is simply
print "Hello World\n"
Carriage returns are used to delineate commands. For example,
print "This is " print "a test\n"
prints “This is a test” on a single line by calling print twice. You can use a semicolon if you prefer ...
Get Code Generation in Action now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.