Ruby documentation center-getting started

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

Ruby simple example

Let's write a function to calculate the factorial. The mathematical definition of the factorial is as follows: N! = 1 (when n = 0)= N * (n-1 )! (Other Cases) In Ruby, you can write as follows: CopyCode The Code is as follows: def fact (N) If

Ruby iterator usage

The iterator was not invented by Ruby. it is widely used in various object-oriented languages. this is also true in Lisp. even so, the concept of iterator is not familiar to many people, so we will give a more detailed introduction here. You know,

Ruby Process Control Method

In this chapter, we will discuss more Ruby process control. Case We use case statements to test ordered conditions. As we have seen, this is close to the switch in C and Java, but it is more powerful. Ruby> I = 8Ruby> case I| When 1, 2 .. 5| Print "

Write a beautiful Rakefile Method

Rake I will not introduce it anymore. Ruby's Make is easier to use than Make in many aspects. Unlike Makefile, Rakefile itself is actually a piece of Ruby code, which has many advantages. On the one hand, in Rake, You Can Do Anything Ruby can do

Ruby determines whether a number is a prime number.

Ruby determines whether a number is a prime number.Prime number. A natural number greater than 1 is called a union number if it cannot be divided by any other natural number except 1 and itself. According to the basic arithmetic theorem, each

Example of Ruby code for getting the current class name

Ruby is currently the most flexible and agile programming language. It has special application methods and can bring a pleasant programming environment to programmers. Here we will learn the skills for Ruby to get the current class name. Using pp (

Capture the essence of Ruby Regular Expression usage

Speaking of Ruby, of course, we need to mention its regular expression mechanism. As a powerful matching language, regular expressions are increasingly used in different fields, from string verification, matching, to web page extraction. Although

Ruby on Rails 3.1 Official release

Rails (Ruby on Rails) 3.1 Official version released! This time there was no jump ticket and it was released as scheduled. The official version provides several new features, including: ◆ Assets Pipeline: A new function Assets pipeline is

Ruby documentation system RDoc 3.10 released

RDoc 3.10 is released. RDoc is a file system for Ruby source code. Like JavaDoc, RDoc can read the original file, analyze the syntax information and comment text in the source code, and generate documents in HTML format. Different from JavaDoc, RDoc

RubyMine 4.5 released, Ruby integrated development environment

RubyMine 4.5 was released. This is a major new version that includes many improvements, including support for MacRuby, Capistrano, Slim, Sass, Rails Engines, development ID, Sinatra, and a series of other improvements. RubyMine is a brand new IDE

Ruby Process Control Method

In this chapter, we will discuss more Ruby process control.CaseWe use case statements to test ordered conditions. As we have seen, this is close to the switch in C and Java, but it is more powerful.Ruby> I = 8Ruby> case I| When 1, 2 .. 5| Print "1 ..

Detailed explanation of rudy overload Methods

In the subclass, we can modify the object behavior by reloading the parent class method.Ruby> class Human| Def identify| Print "I'm a person. \ n"| End| Def train_toll (age)| If age | Print "CED fare. \ n ";| Else| Print "Normal fare. \ n ";| End|

Ruby local variables

Local variables start with lowercase letters or underscores (_). Local variables do not include nil values before initialization like global variables and real variables.Ruby> $ fooNilRuby> @ fooNilRuby> fooERR: (eval): 1: undefined local variable

Ruby rails page Jump (render and redirect_to)

Ruby codeCopy codeThe Code is as follows:If @ user. update_attributes (: password => params [: user] [: password])Flash [: notice] = 'password changed successfully'Redirect_to: action => 'index'ElseRedirect_to: action => 'change _ pass',: id => @

Basic Syntax of common Ruby Libraries

Ruby is a fully object-oriented interpreted scripting language. Its unique nature can help us easily and conveniently compile code. Next let's take a look at some usage of common Ruby libraries. Ruby regular expressions have many similarities

Ruby getting started page 1/5

I. MethodsThe Ruby method definition allows you to set default values for parameters. However, parameters without default values (* and &) cannot be followed by parameters with default values &), that is to say, the following method definition is

RUBY documentation center-getting started

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

Some simple ruby examples

Now let's take a look at the code of some previous sample programs.The following example is shown in the simple example section.Def fact (n)If n = 01ElseN * fact (n-1)EndEndPrint fact (ARGV [0]. to_ I), "\ n"Because this is the first explanation, we

Ruby magic learning notes

1. send messages to the object We can directly send messages to objects:Ruby codeCopy codeThe Code is as follows:Class HelloWorldDef say (name)Print "Hello,", nameEndEndHw = HelloWorld. newHw. send (: say, "world ")We usually use hw. say ("world"),

Total Pages: 114 1 .... 84 85 86 87 88 .... 114 Go to: GO

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.