ruby学习笔记2

  • Finally, you can index arrays using ranges, in which start and end positions are separated by two or three periods. The two-period form includes the end position, while the three-period form does not.
  • Index an array with a negative integer, and it counts from the end.
  • Arrays have a large number of other useful methods. Using these, you can treat arrays as stacks, sets, queues, dequeues, and fifos.
  • 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 .
  • If the last parameter in a method definition is prefixed with an ampersand (such as &action ), Ruby looks for a code block whenever that method is called.

 

    你可能感兴趣的:(Ruby)