Learning Ruby:Features of Ruby

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值