Explanatory language, top-down execution, pure object-oriented, cross-platform, dynamic binding, no multiple inheritance.
NetBeans Sun's development
IRB instructions for fast real-time input and return results quit or exit
RDoc hello.rb Generating HTML documents
Rdoc-f CHM generates CHM documents, relies on the month Microsoft HTML Help Workshop
Gem Ruby Package Management
Gem List List of packages already installed
Gem Install install package
Gem Uninstall uninstalling the installation package
Gem Query Search Package
Gem Help usage assistance
Rebyscript2exe and Exerb can be a tool to transform Ruby into a separate executable file for off-environment.
Naming rules
Local variables start with lowercase letters or underscores.
Global variables start with dollar sign $.
The instance variable begins with @.
Class variables start with @@.
A constant or class name begins with an uppercase letter.
Key words
Module Modules Definition
Class
Def,undef method
Defined? Check type
If,then,else,elsif,case,when,unless conditional statements
For,in,while,until,next (Continue), Break,do,redo (repeats the current cycle), retry (repeats the entire iteration loop), yield loop statement
Not,and,or Logic Judgment
Nil null value
Rescue,ensure Exception Handling
Super,self Object reference
Begin/end the beginning of the block
Begin,end Embedded Module
_file_,_line_ file Related
Alias aliases
Nil is similar to the null in C #, where Ruby has only nil and false for false, and all other expressions are true in logical judgment.
Public,protected,private subclasses can only access protected in protected and private,c# that use the parent class internally
classBaseClassdefpublic_m1 () puts"Basepublic"End protecteddefprotected_m2 () puts"baseprotected"End PrivatedefPrivate_method () puts"baseprivate"EndEndclassmyclass<BaseClassdefcall_basepublic () public_m1 Enddefcall_baseprotected () protected_m2 EnddefCall_baseprivat () Private_method endend#baseclass=baseclass.new#Baseclass.private_method Private Cannot access#baseclass.protected_m2 is protected and cannot be accessedmyclass=MyClass.newmyclass.call_baseprivatmyclass.call_baseprotectedmyclass.call_basepublic
Ruby Prep Work