1. Debug & comment & Print output debug
Ruby is an interpreted language, a script, and on Linux, scripts cannot be executed in three ways:
1. Run the script with the interpreter
Interpreter script File
That is:Ruby script File
2. Run the script directly
In the script file, use the
#! Script Interpreter
Define the script interpreter path, then grant the script execute permission, then run directly
./script File
Can.
3. Run the script inside the interpreter
[Email protected]:/home/ywt/ror_tests/ruby_tests# irb2.1.5:001 > str = "SDFSDF" = "SDFSDF" 2.1.5:002 > puts str SDFSDF = nil2.1.5:003 > Print strsdfsdf = nil2.1.5:004 >
PS: Suggested directly with the first, the second is more troublesome, the third is more ugly (of course try syntax can use this)
Comments
Coment.rb
#single line commentstr = ' Hello World ' =beginthis are a test ofmutiple line comments=endputs str
The test output is as follows:
[Email protected]:/home/ywt/ror_tests/ruby_tests# Ruby Comment.rbhello World
That
#单行注释
=begin Multi-line Comment =end
Print output
Print_test.rb
str = ' Hello World ' puts Strprint strputs ' ========= '
Test output
[Email protected]:/home/ywt/ror_tests/ruby_tests# Ruby Print_test.rbhello Worldhello World =========
That
Puts str = print str + print New_line
(New_line under Windows is ' \ r \ n ', Linux above is ' \ n ')
Class General definition
Class Aclassend
Note: The first letter of a class name must be capitalized! (Python does not require this)
General definition of inheritance
Class Child<fatherend
That is, the inheritance character is ' < ';
Question: Do you support multiple inheritance?
Member member variable member function
[Ruby on Rails] Deep (2) Ruby Basic syntax