A little bit of ruby introduction

Source: Internet
Author: User
Tags documentation

Ruby Installation:

Ruby's installation can go to Ruby's official web site to download the Ruby1.56 Windows Installer package, install the after installation, open the DOS window, input ruby-v display

Ruby 1.8.6 (2007-03-13 patchlevel 0) [I386-mswin32] shows that Ruby has been installed successfully and the version number is Ruby 1.96.

After the installation, in the Start menu-> program appears ruby-186-20 this program. Click on him, there are five submenu below.

1. Ruby documentation (inside of Ruby's online documentation)

2.RubyGems (management tool for Ruby Library)

3.fxri (background and help tools for Ruby)

4.sciTE (an editing tool)

5. Unloading loading Tools

Ruby's execution:

After installing Ruby, Ruby's tools are added to the system's environment variables, so you can use Ruby to compile *.rb files in any path, but you have another option, the Fxri tool after installation. Fxri is a collection of help and backstage tools. He defaults to processing a IRB file in the main function. How you can enter your Helloworld inside, puts "Helloworld" will output Helloworld. So you don't have to write the RB file first and then compile it.

Ruby's Syntax:

Ruby's syntax is very simple. My full-time is a Java program, in Java, every program in the beginning must have a class. For example, HelloWorld can be defined to define the main method in HelloWorld. But Ruby because it can be used as a scripting language. We don't have to be in such trouble. In addition to Java, defining a variable must declare the type of the variable. Ruby doesn't need to directly

A=1

This allows you to declare a variable. Because the default ruby variables are mutable types. That is, you can a=1 then a= "HelloWorld", first let a point to 1 and then let a point to HelloWorld "

Object oriented:

Everything is Object! A thought continues in Ruby. The variables in Ruby are all objects, including the basic types. So you can use

3.times {puts "hello!"}, because 3 is also an object, which has the Times method. In addition 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.