Quick start to Ruby language

Source: Internet
Author: User
Tags expression

Introduced

This is a short introduction to Ruby and it takes only 20 minutes to complete the reading. This assumes that the reader has already installed Ruby, and if you are not installing it, please visit the official Ruby website for download and installation before reading.

Interactive Ruby

Open irb (interactive ruby Shell):

If you are using Mac OS X, open the Terminal window to enter IRB;

If you use Linux, open the shell and enter IRB;

If you are using Windows, please find Ruby->fxri in the Start menu and execute it.

OK, after you open IRB, enter "Hello World" in it.

Ruby, listen to your schedule!

What happened? Have we just written the world's most short "Hello Worlds" program? That's not exactly true. The second line of output is IRB tells us: The evaluation result of the previous expression. If we want to print "Hello world", we need a little more effort:

Puts is a simple print output command in Ruby. What is the "=> nil" behind it? --that's the result of an expression. Puts always returns nil, a way in which Ruby represents "absolutely no value" (absolutely-positively-nothing value), and looks somewhat like a null in Java.

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.