• <Programming Ruby 1.9 The Pragmatic Programmer>读书笔记


    1. Get into the habit of writing code when you’re reading
    2. Almost everything in Ruby is an object
    3. A class is a combination of state and methods that use that state
    4. The standard constructor is called new
    5. Every object has a unique object identifier
    6. you can define instance variables, variables with values that are unique to each instance
    7. Within each class, you can define instance methods. Each method is a chunk of functionality that may be called in the context of the class and from outside the class. These instance methods in turn have access to object’s instance variables and hence to the object’s state.
    8. Methods are invoked by sending a message to an object. The message contains the method’s name, along with any parameters the method may need.
    9. Methods are defined with keyword def, followed by the method name and the method’s parameters between parentheses.

    10. String literals are sequence of characters between single or double quotation marks

    11. Within the string, the sequence #{expression} is replaced by the value of expression

    12. The first characters of a name indicate how the name is used. Local variables, method parameters, and method names should all start with a lowercase letter or with an underscore. Global variables are prefixed with a dollar sign ($), and instance variables begin with an “at” sign (@). Class variables start with two “at” signs (@@). Class names, module names, and constants must start with an uppercase letter.

    13. Ruby’s arrays and hashes are indexed collections. Both store collections of objects, accessible using a key. With arrays, the key is an integer, whereas hashes support any object as a key. Both arrays and hashes grow as needed to hold new elements. It’s more efficient to access array elements, but hashes provide more flexibility. Any particular array or hash can hold objects of differing type

    14. nil is an object, that happens to represent nothing.

    15. Keys in a particular hash must be unique.

    16. A hash by default returns nil when indexed by a key it doesn’t contain.

    17. Symbols are simply constant names that you don’t have to pre declared and that are guaranteed to be unique. A symbol literal starts with a colon and is normally followed by some kind of name

    18. Most statement in Ruby return a value, which means you can use them as conditions.

    19. the method gets returns the next line from the standard input stream or nil when end of file is reached

    20. Ruby treats nil as a false value in conditions

    21. A regular expression is simply a way of specifying a pattern of characters to be matched in a string.

    22. \s matches a whitespace character(space, tab, newline)

    23. \d matches any digit

    24. \w matches any character that may appear in a typical word

    25. a dot(.)matches(almost) any character

    26. The match operator =~ can be used to match a string against a regular expression, if the pattern is found in the string, =~ returns its starting position; otherwise, it returns nil

    27. Code blocks are just trunks of code between braces or between do…end

    28. A method can invoke an associated block one or more times using the Ruby yield statement. You can think of yield as being something like a method call that invokes the block associated with the call to the method containing the yield.

    29. You can provide arguments to the call to yield, and they will be passed to the block. Within the block, you list the names of the parameters to receive these arguments between vertical bars (| params…).

    30. Code block are used throughout the Ruby library to implement iterator, which are methods that return successive elements from some kind of collection.

    31. puts writes its arguments with a newline after each; print also writes its arguments but with no newline. Both can be used to write to any I/O object, but by default they write to standard output.

    32. printf prints its argument under the control of a format string.

    33. gets returns the next line from your program’s standard input stream, it returns nil when it reaches the end of input.

    34. the array ARGV contains each of the arguments passed to the running program

    35. Everything we manipulate in Ruby is an object and every object in Ruby was generated either directly or indirectly from a class

    36. initialize is a special method in Ruby programs. When you call Class.new to create a new object, Ruby allocates some memory to hold an uninitialized object and then calls that object’s initialize method, passing in any parameters that were passed to new

    37. The p method prints out an internal representation of an object

    38. Ruby has a standard message, to_s, that it sends to any object it wants to render as a string

    39. how instance variables work---they’re stored with each object and available to all the instance methods of those objects.

    40. an attribute is just a method

    41. The headers:true option tells the library to parse the first line of the file as the names of the columns

    42. public methods can be called by anyone—no access control is enforced. Methods are public by default (except for initialize, which is always private)

    43. protected methods can be invoked only by objects of the defining class and its subclasses. Access is kept within the family.

    44. private methods cannot be called with an explicit receiver—the receiver is always the current object, also known as self. This means that private methods can be called only in the context of the current object; you can’t invoke another object’s private methods.

    45. If a method is private, it maybe called by any instance of the defining class or its subclasses. If a method is private, it may be called only within the context of the calling object—it is never possible to access another object’s private methods directly, even if the object is of the same class as the caller.

    46. Variables are used to keep track of objects; each variable holds a reference to an object

    47. A variable is simply a reference to an object. Object float around in a big pool somewhere (the heap, most of the time) and are pointed to by variables.

    48. The variables hold references to objects, not the objects themselves

    49. Assignment aliases objects, potentially giving you multiple variables that reference the same object.

    50. To avoid aliasing by using the dup method of String, which creates a new String object with identical contents

    51. You can also prevent anyone from changing a particular object by freezing it. Attempt to alter a frozen object, and Ruby will raise a RuntimeError exception.

    52. The class Array holds a collection of object references. Each object reference occupies a position in the array, identified by a non-negative integer index.

    53. Arrays are indexed using the [] operator. Index an array with a negative integer, and it counts from the end.

    54. [start, count] returns a new array consisting of references to count objects starting at position start

    55. You can index arrays using range, in which start and end positions are separated by two or three periods. The two-period form includes the end position, and the three-period form does not

    56. The first and last methods return the n entries at the head or end of an array without removing them

    57. Hashes are indexed collections of object references, you can index a hash with objects of any type: symbol, strings, regular expressions

    58. Downcase returns a lowercase version of a string, and scan returns an array of substrings that match a given pattern

    59. If we create a hash object using Hash.new(0), the parameter will be used as the hash’s default value—it will be the value returned if you look up a key that isn't yet in the hash

    60. The method each is an iterator—a method that invokes a block of code repeatedly

    61. A block is simply a chunk of code enclosed between either braces or the keywords do and end.

    62. Just like a method, the body of a block is not executed when Ruby first sees it, the block is saved away to be called later

    63. Block can appear in Ruby source code only immediately after the invocation of some method. If the method takes parameter, the block appears after these.

    64. The block is being called by the each method once for each element in the array. The element is passed to the block as the value parameter

    65. If there’s a variable inside a block with the same name as a variable in the same scope outside the block, the two are the same.

    66. If a variable appears only inside a block, then that variable is local to the block.

    67. Parameters to a block are now always local to a block, even if they have the same name as locals in the surrounding scope.

    68. You can now define block local variables by putting them after a semicolon in the block’s parameter list. By making block-local variables, values assigned inside the block will not affect the value of the variable with same name in the outer scope.

    69. A Ruby iterator is simply a method that can invoke a block of code.

    70. Whenever a yield is executed, it invokes the code in the block. When the block exists, control picks back up immediately after the yield.

    71. A block may have any number of arguments

    72. A block may also return a value to the method. The value of the last expression evaluated in the block is passed back to the method as the value of the yield

    73. Collect (also known as map) takes each element from the collection and passes it to the block. The results returned by the block are used to construct a new array.

    74. Succ method, which increments a string value

    75. Each_with_index calls its block with two parameters: the current element of the iteration and the count(which starts at zero, just like array indices)

    76. The inject method lets you accumulate a value across the members of a collection

    77. :+ is the symbol corresponding to the method +

    78. Ruby has a method loop that does nothing but repeatedly invoke its block.

    79. Enumerators are objects

    80. Enumerators are generators and filters

    81. Enumerator object are also enumerable

    82. *args means “collect the actual parameters passed to the method into an array named args”

    83. Closure---variables in the surrounding scope that are referenced in a block remain accessible for the life of that block and the life of any object created from that block

    84. All the methods in a class are automatically accessible to instances of that class.

    85. The < notation means we’re creating a subclass of the thing on the right

    86. The child inherits all the method of its parent.

    87. The superclass method returns the parent of a particular class.

    88. If you don't define an explicit superclass when defining a class, Ruby automatically makes the built-in class Object as that class’s parent

    89. BasicClass is the root class of our hierarchy of classes.

    90. If you call a method in an instance of class Child and that method isn't in Child’s class definition, Ruby will look in the parent class. It goes deeper than that, because if the method isn’t defined in the parent class, Ruby continues looking in the parent’s parent, and so on, through the ancestors until it runs out of classes

    91. Object is an ancestor of every Ruby class (except BasicObject), instances of every Ruby classes have a to_s method defined

    92. When you invoke super, Ruby sends a message to the parent of the current object, asking it to invoke a method of the same name as the method invoking super. It passes this method the parameters that were passed to super.

    93. Modules are a way of grouping together methods, classes, and constants.

    94. :: the scope resolution operator

    95. A module can't have instances, because a module isn't a class. You can include a module within a class definition.

    96. Ruby looks first in the immediately class of an object, then in the mixins included into that classes, and then in superclasses and their mixins. If a class has multiple modules mixed in, the last one included is searched first

    97. In Ruby1.9, every string has an associated encoding. The default encoding of a string literal depends on the encoding of the source file that contains it. With no explicit encoding, a source file (and its strings) will be US-ASCII.

    98. A Struct is a data structure that contains a given set of attributes

    99. The two-dot form creates an inclusive range, and the three-dot from creates a range that excludes the specified high value

    1. The Ruby operator =~ matches a string against a pattern. It returns the character offset into the string at which the match occurred.
    2. Both sub and gsub return a new string
    3. Unlike sub and gsub, sub! And gsub! Return the string only if the pattern is matched. If no match for the pattern is found in the string, they return nil instead.
    4. Once you have a regular expression object, you can match it against a string using the Regexp#match(string) method or the match operators =~ (positive match) and !~(negative match)
    5. The pattern ^ and $ match the beginning and end of a line.
    6. A method name may end with one of ?,! or =. Methods that return a Boolean result are often named with a trailing ?
    7. Ruby lets you specify default values for a method’s argument—values that will be used  if the caller doesn’t pass them explicitly. You do this using an equals sign(=) followed by a Ruby expression.
    8. The body of a method contains normal Ruby expressions. The return value of a method is the value of the last expression executed or the result of an explicit return expression.
    9. You call a method by optionally specifying a receiver, giving the name of the method, and optionally passing some parameters and an optional block.
    10. Every called method returns a value. The value of a method is the value of the last statement executed by the method.
    11. Ruby has a return statement, which exits from the currently executing method. The value of a return is the value of its argument(s)
    12. When you call a method, you can convert any collection or enumerable object into its constituent and pass those elements as individual parameters to the method
    13. If the last argument to a method is preceded by an ampersand, Ruby assumes that it is a Proc object. It removes the parameter list, converts the Proc object into a block, and associates it with the method.
    14. One of the first differences with Ruby is that anything that can reasonably return a value does: just about everything is an expression.
    15. the << method explicitly returns self
    16. Any value that is not nil or the constant false is true
    17. IO#gets, which returns the next line from a fiel, returns nil at the end of file. While line =gets   # process line   end
    18. Both the keyword and and the operator && return their first argument if it is false. Otherwise, they evaluate and return their second argument
    19. The defined? Operator returns nil if its argument is not defined; otherwise, it returns a description of that argument. If the argument is yield, defined? Returns the string “yield” if a code block is associated with the current context.
    20. Ruby classes are instances of class Class. The === operator is defined in Class to test whether the argument is an instance of the receiver or one of its superclass.
    21. the File class provides an each method, which returns each line of a file in turn.
    22. break terminates the immediately enclosing loop; control resumes at the statement following the block, redo repeats current iteration of the loop from the start but without reevaluating the condition or fetching the next element(in an iterator). Next skips to the end of the loop, effectively starting the next iteration.
    23. When an exception is raised, an independent of any subsequent exception handling, Ruby places a reference to the associated Exception object into the global variable $!
    24. You can have multiple rescue clauses in a begin block, and each rescue clause can specify multiple exceptions to catch.
    25. ensure foes after the last rescue clause and contains a chunk of code that will always be executed as the block terminates. It doesn’t matter if the block exits normally, if it raises and rescues an exception, or if it is terminated by an uncaught exception—the ensure block will get run.
    26. catch defines a block that is labeled with the given name. the block is executed normally until a throw is encountered.
    27. When Ruby encounters a throw, it zips back up the call stack looking for a catch block with a matching symbol. When it finds it, Ruby unwinds the stack to that point and terminates the block.
    28. The throw does not have to appear within the static scope of the catch.
    29. A whole set of I/O related methods is implemented in the Kernel module---gets, open, print, putc, puts, readline, readlines, and test
    30. An IO object is a bidirectional channel between a Ruby program and some external resource.
    31. File = File.new(“testfile”, r)#...process the file. # file.close
    32. The first parameter is the filename, the second is the mode string, which lets you open file for reading, writing, or both. After opening the file, we can work with it, writing and/or reading data as needed. Finally, as responsible software citizens, we close the file, ensuring that all buffered data is written and that all related resources are freed.
    33. The method File.open also opens a file, if you associate a block with the call, open invokes the block, passing the newly opened File as a parameter. When the block exists, the file is automatically closed.
    34. File.open(“testfile”, “r”) do |file|

    #...process the file

    End # << file automatically closed here

    1. If an exception is raised inside the block, the file is closed before the exception is propagated on the caller.
    2. Gets reads a line from standard input(or from any files specified on the command line when script was invoked), and file.gets reads a line from the file object file.
    3. IO#each_byte invokes a block with the next 8-bit byte from the IO object, the chr method converts an integer to the corresponding ASCII character.
    4. IO#each_line calls the block with each line from the file.
    5. IO.foreach takes the name of an I/O source, opens it for reading, calls the iterator once for every line in the file, and then closes the file automatically.
    6. With a couple of exceptions, every object you pass to puts and print is converted to a string by calling that object’s to_s method. If for some reason the to_s method doesn't return a valid string, a string is created containing the object’s class name and ID
    7. The nil object will print as the empty string, and an array passed to puts will be written as if each of its element in turn were passed separately to puts.
    8. The constructor for the Fiber class takes a block and returns a fiber object.
    9. Fibers can yield control only back to the code that resumed them
    10. New threads are created with the Thread.new call. It is given a block that contains the code to be run in a new thread.
    11. A thread shares all global, instance, and local variables that are in existence at the time the thread starts.
    12. Local variables created within a thread’s block are truly to that thread—each thread will have its own copy of these variables.
    13. When a Ruby program terminates, all thread are killed, regardless of their states. You can wait for a particular thread to finish by calling that thread’s Thread#join method. The calling thread will block until the given thread is finished. By calling join on each of the requester threads, you can make sure that all three requests have completed before you terminate the main program.
    14. The method Thread#value, returns the value of the last statement executed by the thread.
    15. The current thread is always accessible using Thread.current. you can obtain a list of all threads using Thread.list, which returns a list of all Thread objects that are runnable or stopped. To determine the status of a particular thread, you can use Thread#status and Thread#alive?.
    16. You can adjust the priority of a thread using Thread#priority=. Higher-priority threads will run before lower-priority threads.
    17. A thread can normally access any variables that are in scope when the thread is created. Variables local to the block containing the thread code are local to the thread and are not shared.
    18. Thread.stop stops the current thread, and invoking Thread#run arranges for a particular thread to be run. Thread.pass deschedules the current thread, allowing others to run, and Thread#join and Thread#value suspend the calling thread until a given thread finishes.
    19. Mutex#synchronize, which locks the mutex, runs the code in a block, then unlocks the mutex.
    20. The Queue class, located in the thread library, implements a thread safe queuing mechanism. Multiple threads can add and remove objects from each queue, and each addition and removal is guaranteed to be atomic.
    21. A condition variable is a controlled way of communicating an event(or a condition) between two threads. One thread can wait on the condition, and the other can signal it.
    22. The popen method runs a command as a subprocess and connects that subprocess’s standard input and standard output to a Ruby IO object. Write to the IO object, and the subprocess can read it on standard input. Whatever the subprocess writes is available in the Ruby program by reading from the IO object.
    23. IO.popen works with a block in pretty much the same way as File.open does. If you pass it a command, such as date, the block will be passed an IO object as a parameter. The IO object will be closed automatically when the code block exits, just as it is with File.open.
    24. If you associate a block with Kernal.fork, the code in the block will be run in a Ruby subprocess, and the parent will continue after the block.
    25. Unit testing is testing that focuses on small chunks (units) of code, typically individual methods or lines within methods.
    26. So called behavior-driven development encourages people to write tests in terms of your expectations of the program’s behavior in a given set of circumstances.
    27. A ruby command line consists of three parts: options to the Ruby interpreter, optionally the name of a program to run, and optionally a set of arguments for that program: ruby [options][--][programfile] [arguments]
    28. Any command-line arguments after the program filename are available to your Ruby program in the global array ARGV.
    29. The method Kernal#exit terminates your program, returning a status value to the operating system. However, exit doesn’t terminate immediately. Kernel#exit first raises a SystemExit exception, which you may catch, and then performs a number of cleanup actions, including running any registered at_exit methods and object finalizes.
    30. The site_ruby directories are intended to hold modules and extensions that you’ve added
    31. The Ruby variable $: is an array of places to search for loaded files.
    32. By default, Rake searches the current directory(and its parents) for a file called Rakefile. This file contains definitions for the tasks that Rake can run.
    33. If you define methods or constants in a class, Ruby ensures that their names can be used only on the context of that class(or its objects, in the case of instance methods)
    34. You access the instance method via objects created from the class, and you access the constant by prefixing it with the name of the class followed by a double colon. The double colon(::) is Ruby’s namespace resolution operator. The thing to the left must be a class or module, and the thing to the right is a constant defined in that class or module.
    35. Putting code inside a module or class is a good way of separating it from other code.
    36. The names of classes and modules are themselves just constants
    37. Objects of class Encoding each represent a different character encoding. The Encoding.list method returns a list of the built-in encodings, and the Encoding.aliases method returns a hash where the keys are aliases and the value are the corresponding base encoding.
    38. If nothing overrides the setting, the default encoding for source is US-ASCII
    39. Symbols and regular expression literals that contain only 7-bit characters are encoded using US-ASCII. Otherwise, they will have the encoding of the file that contains them.
    40. Literals containing a \u sequence will always be encoded UTF-8, regardless of the source file encoding.
    41. Ruby’s I/O support both encoding and transcoding of data. Every I/O object has an associated external encoding. This is the encoding of the data being read from or written to the outside world.
    42. All Ruby programs run with the concept of a default external encoding. This is the external encoding that will be used by I/O objects unless you override it when you create the object.
    43. Cookies are a way of letting web applications store their state on the user’s machine.
    44. Sessions: information that persists between requests from a particular web browsers. Sessions emulate a hashlike behavior, letting you associate values with keys. Sessions store the majority of their data on the server.
    45. An OLE object;s properties are automatically set up as attributes of the WIN32OLE object
    46. Ruby expressions and statements are terminated at the end of a line unless the parser can determine that the statement is incomplete. 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.
    47. Every Ruby source file can declare blocks of code to be run as the file is being loaded(the BEGIN blocks) and after the program has finished executing(the END blocks)
    48. A program may include multiple BEGIN and END blocks. BEGIN blocks are executed in the order they are encountered. END blocks are executed in reverse order.
    49. Ruby integers are objects of class Fixnum or Bignum. Fixnum hold integer that fit within the native machine word minus 1 bit. Whenever a Fixnum exceeds this range, it is automatically converted to a Bignum object, whose range is effectively limited only by available memory.
    50. A numeric literal with a decimal point and/or an exponent is turned into a Float object, corresponding to the native architecture’s double data type.
    51. The two-dot form is an inclusive range; the one with three dots is a range that excludes its last element.
    52. Hash keys must respond to the message hash by returning a hash code, and the hash code for a given key must not change. The keys used in hashes must also be comparable using eql?. If eql? Returns true for two keys, then those keys must also have the same hash code.
    53. If you use a String object as a hash key, the hash will duplicate the string internally and will use that copy as its key. The copy will be frozen. Any changes made to the original string will not affect the hash.
    54. If you write your own classes and use instances of them as hash keys, you need to make sure that either (a) the hashes of the key objects don’t change once the objects have been created or (b) you remember to call the Hash#rehash method to reindex the hash whenever a key hash is changed.
    55. A Ruby symbol is an identifier corresponding to a string of characters, often a name. you construct the symbol for a name by preceding the name with a colon, and you can construct the symbol for an arbitrary string by preceding a string literal with a colon
    56. Constant defined within a class or module may be accessed unadorned anywhere within the class or module. Outside the class or module, they may be accessed using the scope operator, :::prefixed by an expression that returns the appropriate class or module object.
    57. Instance variables are available within instance methods throughout a class body. Referencing an uninitialized instance variable return nil. Each instance of a class has a unique set of instance variables. Instance variables are not available to class method.
    58. Local variable are unique in that their scope are statically determined but their existence is established dynamically.
    59. Method parameters are considered to be variables local to that method
    60. Block parameters are assigned values when the block is invoked.
    61. An undefined method still exists—it is simply marked as being undefined.
    62. A method is called by passing its name to a receiver. If no receiver is specified, self is assumed.
    63. Aliasing: alias new_name old_name, this creates a new name that refers to an existing method, operator, global variable, or regular expression backreference. Local variables, instance variables, class variables, and constants may not be aliased.
    64. When a method is aliased, the new name refers to a copy of the original method’s body. If the method is subsequently redefined, the aliased name will still invoke the original implementation.
    65. A Ruby class definition creates or extends an object of class Class by executing the code in body.
    66. A module is basically a class that cannot be instantiated. Like a class, its body is executed during definition, and the resulting Module object is stored in a constant.
    67. Everything in Ruby is just some kind of object
    68. An object’s type is determined by what it can do, not by its class.
    69. A Ruby object has three components: a set of flags, some instance variables, and an associated class.
    70. A Ruby class is itself an object of class Class. It contains all the things an object has plus a set of method definitions and a reference to a superclass (which it itself another class)
    71. The current object is referenced by the built-in, read-only variable self. Self controls how Ruby finds instance variable.
    72. In Ruby, each method call is made on some object. This object is called the receiver of the call.
    73. Inside a class definition, self is set to the class object of the class being defined. This means that instance variables set in a class definition will be available to class methods
    74. Ruby lets you define methods that are specific to a particular object. These are called singleton methods.
    75. If a subclass changes the visibility of a method in a parent, Ruby effectively inserts a hidden proxy method in the subclass that invoke the original method using super. It then sets the visibility of that proxy to whatever you requested.
    76. When you include a module into a Ruby class, the instance methods in that module become available as instance methods of the class
    77. Ruby implements include very simple: the module that you include is effectively added as a superclass of the class being defined. It’s as if the module was the parent of the class that it is mixed in to.
    78. When you include a module in class Example, Ruby constructs a new class object, makes it the superclass of Example, and then sets the superclass of the new class to be original superclass of Example. It then references the module from this new class object in such a way that when you look a method up in this class, it actually looks it up in the module.
    79. The include method effectively adds a module as a superclass of self.It is used inside a class definition to make the instance methods in the module available to instances of the class.
    80. ObjectSpace doesn’t know about objects with immediate values: Fixnum, Symbol, true, false, and nil
    81. You can get the parent of any particular class using Class#superclass.
    82. The Object#send method lets you tell an object to invoke a method by name. It works on any object
    83. A Method object is like a Proc objet: it represents a chunk of code and a context in which it executes.
    84. The special variable __FILE__ contains the name of the current source file.
    85. Saving an object and some or all of its components is done using the method Marshal.dump
    86. Not all objects can be dumped: bindings, procedure objects, instances of class IO, and singleton objects cannot be saved outside the running Ruby environment
    87. All information from the outside world can be marked as tainted. When running in a safe mode, potentially dangerous methods will raise a SecurityError if passed a tainted object.
    88. Any Ruby object derived from some external source is automatically marked as being tainted. If your program uses a tainted object to derive a new object, then that new object will also be tainted.
    89. Objects created while Ruby’s safe level is less than 3 are trusted. Objects created while the safe level is 3 or 4 will be untrusted.
    90. &: Set intersection—returns a new array containing elements common to the two arrays, with no duplicates.
    91. BasicObject is the root of Ruby’s class hierarchy.
    92. Bit Reference—Returns the nth bit in the (assumend) binary representation of big, where big[0] os the least significant bit.
    93. Classes in Ruby are first-class objects—each is an instance of class Class. When a new class is defined, an object of type Class is created and assigned to a constant. When Name.new is called to create a new object, the new instance method in Class is run by default, which in turn invokes allocate to allocate memory for the object, before finally calling the new object’s initialize method.
    94. Allocate allocates space for a new object of cls’s class. The returned object must be an instance of cls. Calling new is basically the same as calling the class method allocate to create an object, followed by calling initialize on that new object. You cannot override allocate in normal programs; Ruby invokes it without going through conventional method dispatch.
    95. Objects of class Dir are directory streams representing directories in the underlying file system.
    96. An encoding describes how to map the binary data in the internal representation of strings into characters.
    97. A fiber is a lightweight asymmetrical coroutine. Code in a fiber is created in a suspended state. It runs when resumed and can suspend itself(passing a value back to the code that resumed it)
    98. Each file has three associated times. The atime is the time the file was last accessed. The ctime is the time that the file status were last changed. The mtime is the time the file’s data was last modified.
    99. A Hash is a collection of key/value pairs. It is similar to an Array, except that indexing is done via arbitrary keys of any object type, not an integer index. Hashes have a default value.
    100. Method objects are created by Object#method. They are associated with a particular object(not just with a class).
    101. A Module is a collection of modules and constants. The methods in a module may be instance methods or module methods. Instance methods appear as methods in a class when the module is included; module methods do not.
    102. A mutex is a semaphore object that can be used to synchronize access to resources shared across threads.
    103. Object is the parent class of all classes in Ruby. Its methods are therefore available to all objects unless explicitly overridden.
    104. Proc objects are blocks of code that have been bound to a set of local variables. Once bound, the code may be called in different contexts and still access those variables.
    105. A String object holds and manipulates a sequence of bytes, typically representing characters.
    106. Continuation objects are generated by the KErnal#callcc method, which becomes available only when the continuation library is loaded. They hold a return address and execution context, allowing a nonlocal return to the end of the callcc block from anywhere within a program.
    107. CSV.open works like File.open, not File.foreach, and options are passed as a hash and not positional parameters.
    108. DBM files implement simple, hashlike persistent stores.
    109. The Find module supports  the top-down traversal of a set of file paths, given as arguments to the find method
    110. Class IPAddr holds and manuipulate Internet Protocol(IP) addresses. Each address contains three parts: an address, a mask, and an address family.
    111. The Singleton design pattern ensures that only one instance of a particular class may be created for the lifetime of a program
    112. In Ruby, objects are not eligible for garbage collection if references still exist to them.
  • 相关阅读:
    Java appendReplacement 和 appendTail 方法
    UVA Mapping the Swaps
    oppo X907刷机包 COLOROS 1.0 正式版公布 安卓4.2.2
    MVC传递Model之TempData、ViewData、ViewBag差别及用途
    新加坡电视剧--幸福料理Spice Up每集剧情 Episodic Synopsis_wkh73_新浪博客
    七分食三分练,“七分食”希望解决的是健身人群的独特用餐需求
    基于Redis的BloomFilter算法去重
    砍高层“手脚”、中层“屁股”、基层“脑袋”……任正非管人用人之道竟是如此简单!
    (2)注码法的价值
    全球购 颂拓SUUNTO手表AMBIT3拓野3户外运动石英男表巅峰系列 巅峰蓝宝石心率 SS020673000【图片 价格 品牌 报价】-京东
  • 原文地址:https://www.cnblogs.com/bluescorpio/p/2937611.html
Copyright © 2020-2023  润新知