Namespaces, Source Files, and Distribution(Chapter 16 of Programming Ruby)

作者: Ray Z
发布时间:2015-07-13 11:31:22

  Putting code inside a module or class is a good way of separating it from other code.Ruby’s Math module is a good example—it defines constants such as Math::PI and Math::E and methods such as Math.sin and Math.cos. You can access these constants and methods via the Math module object:
  Math::E # => 2.71828182845905
  Math.sin(Math::PI/6.0) # => 0.5 

标签: MM Ruby
来源:http://www.cnblogs.com/zhtf2014/archive/2010/07/16/1779240.h

推荐: