Java to Ruby

Source: Internet
Author: User

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.