Ruby documentation center-getting started

Source: Internet
Author: User

First, you must check whether Ruby has been installed. At the shell prompt ("%" here, so do not enter % ),

% Ruby-V

(-V tells the interpreter to print out the ruby version) and press Enter. If Ruby is installed, you will see information similar to the following:

% Ruby-V
Ruby 1.6.6 () [i586-linux]

If Ruby is not installed, you can ask the Administrator to install it, or you can do it yourself. Ruby is a free software without installation or restrictions.

Now, let's play with Ruby. You can place a ruby directly on the command line using a-e parameter.Program:

% Ruby-e 'print "Hello world \ n "'
Hello World

Generally, Ruby programs are stored in a file.

% Cat> test. Rb
Print "Hello world \ n"
^ D
% CAT test. Rb
Print "Hello world \ n"
% Ruby test. Rb
Hello World

^ D Refers to control-D. The above is in Unix. If you use dos, it will be like this:

C: \ Ruby> copy con: Test. Rb
Print "Hello world \ n"
^ Z
C: \ Ruby> type test. Rb
Print "Hello world \ n"
C: \ Ruby> Ruby test. Rb
Hello World

When writing is more practical than thisCodeYou will want to use a real text editor!

Some Amazing complex and useful things can be made using a line of command mini program. for example, replace Foo in all C source programs and header files in the current directory with bar and append the original files ". bak "backup:

% Ruby-I. Bak-PE 'sub "foo", "bar" '*. [CH]

This program is similar to the cat command in Unix (but slower than cat ):

% Ruby-pe 0 file

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.