The Ruby Programming Language
David Flanagan, Yukihiro Matsumoto
Format: PDF / Kindle (mobi) / ePub
The Ruby Programming Language is the authoritative guide to Ruby and provides comprehensive coverage of versions 1.8 and 1.9 of the language. It was written (and illustrated!) by an all-star team:
- Yukihiro "Matz" Matsumoto, creator, designer and lead developer of Ruby and author of Ruby in a Nutshell, which has been expanded and revised to become this book.
- why the lucky stiff, artist and Ruby programmer extraordinaire.
This book begins with a quick-start tutorial to the language, and then explains the language in detail from the bottom up: from lexical and syntactic structure to datatypes to expressions and statements and on through methods, blocks, lambdas, closures, classes and modules.
The book also includes a long and thorough introduction to the rich API of the Ruby platform, demonstrating -- with heavily-commented example code -- Ruby's facilities for text processing, numeric manipulation, collections, input/output, networking, and concurrency. An entire chapter is devoted to Ruby's metaprogramming capabilities.
The Ruby Programming Language documents the Ruby language definitively but without the formality of a language specification. It is written for experienced programmers who are new to Ruby, and for current Ruby programmers who want to challenge their understanding and increase their mastery of the language.
Structure and Execution of Ruby Programs 2.2.1 Block Structure in Ruby Ruby programs have a block structure. Module, class, and method definitions, and most of Ruby’s statements, include blocks of nested code. These blocks are delimited by keywords or punctuation and, by convention, are indented two spaces relative to the delimiters. There are two kinds of blocks in Ruby programs. One kind is formally called a “block.” These blocks are the chunks of code associated with or passed to iterator.
Constants, they must be written in uppercase, and hyphens in the encoding names must be converted to underscores. Ruby 1.9 also supports the US-ASCII encoding, the European encodings ISO-8859-1 through ISO-8859-15, and the Unicode UTF-16 and UTF-32 encodings in big-endian and little-endian variants. If you have an encoding name as a string and want to obtain the corresponding Encoding object, use the Encoding.find factory method: encoding = Encoding.find("utf-8") Using Encoding.find causes the.
Are covered in Chapters 6 and 7. This chapter covers the simpler, more traditional sort of expressions. The simplest expressions are literal values, which we already documented in Chapter 3. This chapter explains variable and constant references, method invocations, assignment, and compound expressions created by combining smaller expressions with operators. 4.1 Literals and Keyword Literals Literals are values such as 1.0, 'hello world', and  that are embedded directly into your program text.
Discarded 220.127.116.11 Multiple lvalues, single array rvalue When there are multiple lvalues and only a single rvalue, Ruby attempts to expand the rvalue into a list of values to assign. If the rvalue is an array, Ruby expands the array so that each element becomes its own rvalue. If the rvalue is not an array but implements a to_ary method, Ruby invokes that method and then expands the array it returns: x, y, z = [1, 2, 3] # Same as x,y,z = 1,2,3 The parallel assignment has been transformed so.
Statement. Raising an exception transfers the flow-ofcontrol to exception handling code. This is like using the break statement to exit from a loop. As we’ll see, though, exceptions are quite different from the break statement; they may transfer control out of many enclosing blocks and even up the call stack in order to reach the exception handler. Ruby uses the Kernel method raise to raise exceptions, and uses a rescue clause to handle exceptions. Exceptions raised by raise are instances of the.