Basic Ruby tutorial,

Source: Internet
Author: User

Basic Ruby tutorial,

1. Basic Ruby knowledge

1. Ruby

Ruby is a scripting language

Ruby is an object-oriented language

Ruby is a cross-platform language

Ruby is open source software.

2. Ruby getting started Book recommendation

Ruby. Programming: Learning Programming from the father of Ruby (version 2nd)

3. Common Ruby development tools

Any text editor can be used to compile Ruby code, as long as the file is saved at the end of ". rb ".

ScITE

Eclipse (using RDT Plugin)

NetBeans, etc.

4. Ruby's first program

= Begin

The first program "Hello World"

Note: 1. Ruby is a case-sensitive language.

= End

Print "Hello \" Ruby \ "\ n"

P "Hello Ruby \ n"

Puts "Hello \ Ruby"

Puts "Hello", "Good", "xiaoming"

P "Hello", "Good", "xiaoming"

Print "Hello", "Good", "xiaoming"

 

> Ruby test. rb

Hello "Ruby"

"Hello Ruby \ n"

Hello \ Ruby

Hello

Good

Xiaoming

"Hello"

"Good"

"Xiaoming"

HelloGoodxiaoming> Exit code: 0

5. Basic Ruby knowledge-Numbers

  

Ruby contains five built-in classes used to represent numbers. In addition, the standard library also contains three Numeric classes. All Numeric objects in Ruby are Numeric class instances, all integers are Integer instances. If an Integer can be contained in a 31-bit binary value, it is an instance of the Fixnum class. Otherwise, it is an instance of the Bignum class, the Bignum object is an integer of any size. If the operand of an operation is a Fixnum object, the result is also true. Ruby uses the Float class to represent the real number in an approximation. This class uses the floating point representation on the local platform. The Complex class represents the plural, and the BigDecimal class represents the real number with any precision. It uses the decimal notation instead of the binary. The Rational class represents the Rational number, that is, the number obtained after the two integers are divided.

  

 

To be continued ......

  

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.