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 program directly on the command line using a-e parameter:

% 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 code that is more practical than this, you 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.