Ruby getting started-Ruby Installation

Source: Internet
Author: User

To install Ruby, go to the Ruby official website to download the Windows Installation Package of Ruby1.56. After installing ruby, open the Dos window and enter Ruby-v to display it.

Ruby 1.8.6 (patchlevel 0) [i386-mswin32] indicates that Ruby has been installed successfully and the version is Ruby 1.96.

After installation, the Ruby-186-20 program is displayed in the Start Menu> program. Open him. There are five sub-menus below.

1. Ruby Documentation (which contains Ruby Online Documentation)

2. RubyGems (a Ruby library management tool)

3. fxri (Ruby background and help tools)

4. sciTE (an editing tool)

5. upload tool

Ruby execution:

After Ruby is installed, Ruby tools are added to the environment variables of the system, so ruby can be used for compilation in any path *. rb files, but you also have other options, that is, the installed fxri tool. Fxri is a collection of help and background tools. It is the Main function that processes an irb file by default. How can you input your Helloworld, puts "helloworld" in it to output helloworld. In this way, you do not need to write the rb file first and then compile it.

Ruby Syntax:

Ruby syntax is very simple. My full-time job is a Java program. in Java, each program must have a class at the beginning. For example, if HelloWorld is defined, the main method can be defined in Helloworld. But Ruby can be used as a scripting language. We don't have to worry about it. In addition, in Java, defining a variable must declare the type of the variable. Ruby is not directly needed.

A = 1

In this way, you can declare a variable. By default, Ruby variables are of variable type. That is, a = 1 and then a = "helloworld", let a point to 1 first, and then let a point to helloworld"

Object-oriented:

Everything is Object! Another idea is continued in Ruby. In Ruby, all variables are objects, including basic types. So you can use

3. times {puts "Hello! "}, Because 3 is also an object, which contains the times method. You can also use "gin joint ". length» 9 "Rick ". index ("c")» 2-1942.abs» 1942 sam. play (aSong)» "duh dum, da dum de dum..."

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.