Ror has been blooming abroad for a long time, but it has always been a bit cool in China. Except javaeye, I rarely hear the success stories of domestic ror. On the infoq Chinese site a few days ago, I saw a piece of news from Jeff Xiong. I
One instance can be used to describe the problem
@ Title = "test"
P' #{@ title} '# Original output#=> "\#{@ title} "P "#{@ title} "# Calculate the value of the variable and convert it into a string output.#=> " test "# The content can also be
Ruby is a dynamic language that allows you to change the class definition at any time. For example, if a class already exists when we define it, the definition at this time is to append the previous class, rather than re-define it.
Code
1. Establish an HTTP connection (Send request parameters through get)
Require "open-Uri" # Write the GET Request Parameters in the uri url uri = 'HTTP: // URI 'html_response = nil open (URI) do | HTTP | html_response = http. read end puts
When we talk about inheritance, we usually separate them into interface inheritance and implementation inheritance. For single inheritance, it is easy to understand and use both implement inheritance and interface inheritance. Even so, in C ++'s
N = [1, 2, 3, nil, nil] P nn1 = n. compactp n1n2 = n. Compact! P n2p n
It mainly involves communication with limited levels. I like research and I am sorry for it.
Let's talk about an array loop first.
Arr = [1, 2, 3] n = arr
Analysis: [
• First and foremost, run your scripts with warnings enabled (the-W command-line
Option ).
• If you happen to forget a "," in an argument list-especially to print-you can
Produce some very odd error messages.
• A parse error at the last line of the
(1) Everything in ruby is an object, including a constant.For example, you can use the. Class Attribute to view the type of an object. You can see that the type of constant 1 is fixnum, and 1 is just an instance of fixnum. You can also use the-37
There are three types of modifying keywords for Ruby member access, which are the same as C.1 private can only be the method called by this object2 protected can only be called for this object and its sub-objects3. Public allows any object to call
The iterator is a feature of advanced languages and is very easy to use.
For example, array Iteration[1, 2, 3]. Each {| n | puts N. to_s}(1. 100). Each {| n | puts N. to_s} iterates each element
String Iteration"ABDC". each_byte {| CHR | printf "
Complaints when learning Ruby
I accidentally started to learn Ruby. After a New Year's Day, I learned Ruby for two years (in fact, just a few days ).
In general, it is a bit rejected because it does not feel good.
I learned a little about VB
1. = (equal to) and! = (Not equal)
Returns true and flase if the values of the two objects are equal.
A = 1; B = 1.0; A = B # True
2. eql?
Returns true and flase if the values and types of the two objects are equal.
A = 1; B = 1.0; A. eql? (B)
1. Ruby-China website source code package: https://github.com/huacnlee/ruby-china
$ cd ~/workspace$ git clone https://github.com/huacnlee/ruby-china.git
2. If you want to worry about it, do not try to install it in windows. Last night, it took 30
Class array def iterate! (& Code) # note that the & Symbol self is used here. each_with_index do | N, I | self [I] = code. call (n) end endendarr = [1, 2, 4] arr. iterate! Do | n ** 2end # [1, 4, 9, 16]
When I read the code today, it was masked
Recently, I am reading the ruby hacking Guide (the ruby source code is completely explained, and the ruby hacker has been fully explained.
I saw a team translating on the Internet. Unfortunately, I didn't find any good translation results, so I had
Finally, I started to translate some Japanese sentences that I could not understand. I would like to ask the Japanese mm next to me.
MM read it for the first time, did not understand it, and did not understand it for the second time. Japanese ....
Program:
1: formula (that is, code line, haha)2: Termination of the program
Programs are composed of sub-statements. Use semicolons (;) or line breaks (;) to distinguish between formulas and formulas.In the middle of a row, separate them with
6, Using a Thread Group
A thread group is a way to manage threads. It logically associates threads with each other. Generally, all threads belong to the Default thread group (it is a class constant ). If a new thread group is created, the new thread
As you know, ruby strings are called first-class objects and use a large number of query and operation methods. A basic string operation is to split a string into multiple sub-strings. If you have a string, such as "foo, bar, baz", and you want the
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