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" }
def call_block
puts "Start of method"
yield
yield
puts "End of method"
end
call_block { puts "In the block" }
相关文章推荐
- When Trouble Strikes(Chapter 14 of Programming Ruby)
- Containers, Blocks, and Iterators(Chapter 4 of Programming Ruby)
- More About Methods(Chapter 8 of Programming Ruby)
- Exceptions, Catch, and Throw(Chapter 10 of Programming Ruby)
- Fibers, Threads, and Processes(Chapter 12 of Programming Ruby)
- Sharing Functionality: Inheritance, Modules, and Mixins(Chapter 5 of Programming Ruby)
- Ruby and Its World(Chapter 15 of Programming Ruby)
- Classes, Objects, and Variables(Chapter 3 of Programming Ruby)
- Standard Types(Chapter 6 of Programming Ruby)
- Namespaces, Source Files, and Distribution(Chapter 16 of Programming Ruby)
- Expressions(Chapter 9 of Programming Ruby)
- Basic Input and Output(Chapter 11 of Programming Ruby)
- Unit Testing(Chapter 13 of Programming Ruby)
- Chapter 13. Playing God: Basic Physics Modeling (Tricks.of.the.Windows.Game.Programming.Gurus,.Second.Edition)
- Notes to the Reader(Chapter 1 of The C++ Programming Language)
- Objective-C(Chapter 3 of Cocoa Programming for Mac OS X)
- The kayword "new" of CPP programming language
- Archiving(Chapter 10 of Cocoa Programming for Mac OS X)
- Images and Mouse Events(Chapter 18 of Cocoa Programming for Mac OS X)
- Exception Handling(Chapter 14 of The C++ Programming Language)