Ruby study Note 1

Source: Internet
Author: User
Tags ruby on rails
Write a record of the Ruby Blog system. It is also a bit of a record for me to learn Ruby.

First, I will introduce my learning environment.
System: ubuntu12.04
Documents: techotopia, Ruby documents, the hard way learn Ruby and other documents
Record: youdao cloud notes

Ruby

When I learn Ruby, I usually introduce the history and development of Ruby, but I think this is a bit of nonsense,

Ruby is written by a Japanese. It is an explanatory language.

Start

On Ubuntu, first determine whether it is installed Ruby.

1
ruby -v

If it is installed, the current number will be printed.

/**

123456
[Email protected]: ~ $ Ruby-V program 'Ruby 'is included in the following software packages: * ruby1.8 * ruby1.9.1 please try: sudo apt-Get install <selected software package>

**/

Here, there are some differences between ruby1.8 and ruby1.9.1, and there are incompatibility issues.
Therefore, you must select the appropriate one.
Previously we mentioned that bianjiqiopenshift uses the Ruby on Rails development interface, using ruby1.9.3
Therefore, I am using a later version. You can choose one based on your needs.
For the differences between specific versions, You can Google it.

Install
1
sudo apt-get install ruby1.9.3

Then check whether the installation is successful:

12
ruby -vruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

We can see the ruby version number.

First Ruby command

Execute the first ruby command.

1
ruby -e ‘print "heloo ruby!\n"‘

-E is a parameter that enables Ruby to execute a line of Ruby statements on the command line of the terminal. You can also execute multiple lines of Ruby statements on one line of command line.
Refer:
The '-e' flag only allows a single line of code to be executed, but that does not mean that multiple '-e' flags cannot be placed on a single command line to execute multiple lines:

123
[email protected]:~$ ruby -e ‘print "hello ruby!\n"‘ -e ‘print "Hello Jeiao\n"‘hello ruby!Hello Jeiao

Here, print can be replaced with puts or P. There are differences. I 've got more contact in the future. Let's talk about it, Mark.

 

 

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.