A little more complexCodeIt is easy to get dizzy by the Representation Methods of various Ruby conventions.
(If the first part of the identifier is a lowercase letter or "_", the identifier is a local variable or method call .)
(An identifier
Block, lambda, and proc are important in ruby.
A block is an anonymous function. It is called using a field in the called method. Block is mainly used for iteration.
RubyCode:
Arr = [1, 2, 4, 5]Arr. Each {| item | puts item}
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
Arr = [1, 2, 3]
1) arr2 = arr. each {| element = element * 2} # Both arr and arr2 are still equal to [1, 2, 3] each. The changes to elements in the original array traversal are not saved.2) arr2 = arr. map {| element = element * 2} # arr is equal
I will first write down some of my experiences over the past two days.
1. How to Use gem to delete new versions and retain old versions
We know that the method for clearing the old version of GEM is to update the new version of GEM cleanup. But if
Ruby Deployment Tool Overview: vglad 1.3 release and Capistrano handover and Maintenance
The recent message about jamis Buck's stopping Capistrano development has caused many people to worry about the future of the Deployment Tool. Fortunately, the
You have written a script for the new feature, but this feature does not allow adding records of the same name. What should I do?
Delete related records during initialization? If you are not familiar with the business, the table structure, and the
In Ruby, the so-called block-based method refers to the abstraction of the control structure. It was initially designed to abstract loops, so it is also called an iterator.Syntax: method_name do... end or method_name {}
1
#
Block call
Ruby require vs load vs include vs extend
In general:
Require vs load: require is loaded only once, and load may be loaded multiple times.
Include vs extend: the methods in the include module are the instance methods of the class, and the
Ruby is...
A dynamic, open source programming language with a focus on simplicity and productifunctionality. It has an elegant syntax that is natural to read and easy to write.
Translate and organize documents of common Ruby libraries, and
I. Judgment Structure
If
ExpressionElsif expression
Else
End
IfExpression then end#Use then when writing a line
IfExpression#When the expression returns true, run the preceding code.
... Unless expression#When the expression is
Ruby supports arrays and hash. Both arrays and hash are accessed through indexes. The difference is that arrays are indexed by numbers, while hash indexes can be any object, therefore, the array access speed is faster (direct positioning), while
This rexml library can be used for parsing XML documents in ruby.
The rexml library is an XML toolkit of Ruby. It is written in pure Ruby and complies with the xml1.0 specification.In ruby1.8 and later versions, the ruby standard library will
Conversion of GBK and UTF-8
Use GBK instead of gb2312, because GBK not only contains simplified Chinese, but also traditional Chinese, is a large character set.
#
Utf8 to GBK
Def
U2g (ucode)Begin
"
# {Iconv. Conv ('gbk', 'utf-8',
I have already introduced something about the ruby language. Next I will start to learn the rails platform that makes Ruby popular.The rails platform can build standard MVC applications. MVC is the controller, view, and model.
The command for
Http://developer.51cto.com/art/200703/41243.htm
Introduction
This is a short Ruby entry, and it takes only 20 minutes to complete. Here we assume that you have installed Ruby. If you have not installed Ruby, visit the official Ruby website to
Http://article.yeeyan.org/view/52654/18184
Rack provides interfaces between the Web server and the ruby development framework. It frees framework writers from the heavy burden of writing a processing module for each web server, saving a lot of
ATTR _ * in ruby _*
In Java, get and set are used to assign values to and read variables.
In ruby:
Read:
Def name @ nameend
Assignment:
Def name = (myname) @ name = mynameend
You can use attr_reader and attr_writer, or attr_accessor.
For
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.