Ray's playground

 

Ruby.new(Chapter 2 of Programming Ruby)

  Ruby uses a convention that may seem strange at first: 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 (@@).2 Finally, class names, module names, and constants must start with an uppercase letter.

 

 

1 def call_block
2   puts "Start of method"
3   yield
4   yield
5   puts "End of method"
6 end
7 call_block { puts "In the block" } 

posted on 2010-06-26 21:50  Ray Z  阅读(153)  评论(0编辑  收藏  举报

导航