Optional ArgumentsSet default arguments, when we don ' t need to call it, we can simply skip it.def new_game (name, Year=nil, system=nil) { name:name, year:year, system:system = New_game ("Street figher II")Options Hash ArgumentSometimes,
Open source, cross-platform (Windows, Linux, UNIX, etc.)scripting language (less efficient), no need to compile, run directlyGrammar Nature, IntroductionEverything is an object.Flexible language design (feel free to change the original
The count-taking method in Ruby is the most humane and flexible in the language I touch, which can be illustrated here for example:First, print 7 times "Hello,world", as follows:7.times{puts "Hello,world"} #在这里, puts function is equivalent to print+
ARGFAn Io object that connects all the files specified in the argv into a file. If argv is empty, then it represents standard input. Synonyms $ArgvAn array that contains all the parameters specified by the command line. Synonyms $*DATARepresents all
Usually we use the following form when we write code, construct nested data, or initialize a variable:A | | = [] ; A = B | | C A = a | | []This form ensures that the variables are initialized when they are accessed, giving us a great deal of
Ruby-vVerify that Ruby is installed successfully and view the version numberRuby-e "puts ' hello '"Verify that Ruby is successfully installed and executableGem--versionLook at the version of RubyGems, for example, I have an output of 1.5.2 at this
There are a number of classic drive architectures in Ruby, such as enumerators and generators. This is a simple introduction to the concept of generators. The generator is a function requirement that produces an object at a time, or a method that
This two weeks work more content, usually oneself also a bit not in the state, learn something a little, take advantage of now still a bit state, hurriedly review before study of Ruby Bar.Ruby was the first language that I really started to touch
In Ruby we want to implement the method of traversing the specified directory, the method of the Internet is also very much, we can refer to reference, as shown in the following traverse.rb file content:#!/usr/bin/ruby def traverse (filepath) if
First, take a look at the simple factory modelAdvantages of the Simple factory model: The factory class contains the necessary logical judgments, dynamically instantiating the relevant classes based on the client's choice, and, for the client, the
Chapter IIClass inheritance, properties, class variables1. How to declare a subclassclass Treasure This way the attribute name,description in the thing class is inherited by Treasure2. What are the parameters of the following three ways to pass in
There are three machines and the operating system is centos 6.3 64-bit: 172.16.9.100, install nginx server; the other two 172.16.9.101 and 172.16.9.102 install unicorn as the ROR application server. Ensure that Ruby and rails have been configured on
How to build a ruby gem
1. First you will creata a user in rubygem.org (https://rubygems.org /)
2. Create the directory structure like this:
Java code
$ Tree
.
── Cc_hola.gemspec
── Lib
── Cc_hola.rb
You can use any name but you must
Construct string literal
Method 1:A string enclosed by single or double quotation marks, such as "hello ".Method 2:% Q is used with the delimiter, and % Q represents single quotes.STR = % Q! He/lo!Method 3:% Q is used with the delimiter, and % Q
Basic Ruby knowledge: Data Type and basic ruby knowledge
I. numeric type
(1) IntegerThere are two types of integer types. If the value is within 31 characters (four bytes), it is a Fixnum instance. If the value is exceeded, it is a Bignum
Examples of commonly used string processing functions in Ruby and ruby instances
1. Return the length of the stringCopy codeThe Code is as follows:Str. length => integer2. Determine whether the string contains another stringCopy codeThe Code is as
Conditional judgment exists in programming languages. The conditional judgment in Ruby is similar to that in Java. Of course, there are still some differences.
Conditions for condition determination in Ruby:
1) Comparison operations such as =, can
It took two weeks for Google to deploy the method. Many methods were useless. I finally used the control variable method to modify the configuration file one by one.
First,/etc/nginx/vhosts/limlog.sloger.info. conf and config/puma. rb
##
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