Learning Ruby:Features of Ruby

來源:互聯網
上載者:User

Ruby is an open-source and is freely available on the Web, but it is subject to a license.(開源協議...)

Ruby is a general-purpose, interpreted programming language.(多用途、解釋型)

Ruby is a true object-oriented programming language.(物件導向)

Ruby is a server-side scripting language similar to Python and PERL.(伺服器端指令碼)

Ruby can be used to write Common Gateway Interface (CGI) scripts.

Ruby can be embeded into Hypertext Markup Language (HTML).

Ruby has a clean and easy syntax that allows a new developer to learn Ruby very quickly and easily.

Ruby has similar syntax to that of many programming languages such as C++ and Perl.

Ruby is very much scalable and big programs written in Ruby are easily maintainable.

Ruby can be used for developing Internet and intranet applications.

Ruby can be installed in Windows and POSIX environments.

Ruby support many GUI tools such as Tcl/Tk, GTK, and OpenGL.

Ruby can easily be connected to DB2, MySQL, Oracle, and Sybase.

Ruby has a rich set of built-in functions which can be used directly into Ruby scripts。



Ruby is a perfect Object Oriented Programming Language. The features of the object-oriented programming language include:  物件導向

Data Encapsulation: 封裝

Data Abstraction: 抽象

Polymorphism: 多態

Inheritance: 繼承

Defining a Class in Ruby:
To implement object-oriented programming by using Ruby, you need to first learn how to create objects and classes in Ruby.

A class in Ruby always starts with the keyword class followed by the name of the class. The name should always be in initial capitals. The class Customer can be displayed as:

Variables in a Ruby Class:(Ruby變數)
Ruby provides four types of variables:

Local Variables: Local variables are the variables that are defined in a method. Local variables are not available outside the method. You will see more detail about method in subsequent chapter. Local variables begin with a lowercase letter or _.  

Instance Variables: Instance variables are available across methods for any particular instance or object. That means that instance variables change from object to object. Instance variables are preceded by the at sign (@) followed by the variable name.

Class Variables: Class variables are available across different objects. A class variable belongs to the class and is a characteristic of a class. They are preceded by the sign @@ and are followed by the variable name.

Global Variables: Class variables are not available across classes. If you want to have a single variable, which is available across classes, you need to define a global variable. The global variables are always preceded by the dollar sign ($).


摘自:http://www.tutorialspoint.com/ruby/ruby_overview.htm

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.