您的位置:首页 > 编程语言 > Ruby

Ruby.new(Chapter 2 of Programming Ruby)

2010-06-26 21:50 851 查看
  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.


def call_block
puts "Start of method"
yield
yield
puts "End of method"
end
call_block { puts "In the block" }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: