Original
Http://www.ruby-lang.org/zh_cn/documentation/ruby-from-other-languages/to-ruby-from-java/
Omit blabla
Similarity:
Memory Management, with the garbage collection function
All objects have types.
Public, private, and protected Methods
There is a built-in Doc tool (rdoc in Ruby), which is very similar to javadoc.
Different points:
Ruby does not need to be compiled.
There are different GUI toolkits.
Define class end with the end keyword
Require replaces Import
All variables are private and must be called externally.
Brackets in method are optional and are often omitted.
All objects are of the object type, including numbers.
There is no static type verification.
Variable names are only tags and do not need to be declared
You do not need to declare the variables, just define them: a = [1, 2, 3]
No forced conversion of casting. You only need to call the method. Unit tests must tell you before running to see the error?
Foo = Foo. New ("hi") instead of Foo = new Foo ("hi ")
Constructor is always called "initialize" instead of the class name.
"Mixin's" replaces Interface
Yaml is more popular than XML
Nil instead of null
= And equals () have different functions. = Is it equal? equals () checks whether two objects are the same?