We always want to classify unknown events. When it happens, pass a piece
Code Is the easiest solution, that is, we want to process code like processing data.
A new process object can be created through proc:
Ruby> quux = proc {| Print
There are not many Ruby books. I have collected these books from the Internet. Download them and click images.
Programming Ruby, Second Edition: getting started with Ruby, Version 2, required for learning Ruby
After reading Ruby for a few days, I found many well-known syntax features in C #. Ruby was available a few years ago:
1. The Params keyword in C #
Class program {static void main (string [] ARGs) {console. writeline (sum (); console. writeline (
1. Open and read files
File = file. Open ("cnblogslink.txt") file. Each {| Line | print "# {file. lineno}.", line} file. Close
Output:
1.Community 2. News
3. Community
4. News
5. Recruitment
6. Bo Wen
7. Group8. Flash9. Network
Get the currently running method name in Ruby on bigbold
Code Fragment:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Module KernelPrivate
Def
This_method_nameCaller [0]
= ~
/
'
Complained todayThe blog has not been updated for many days, which affects reading mood. I just need to start it. ^_^
# Part One
Afile = file. New ("C: \ 1.txt"," W ")
Afile. Puts "The 1"
Afile. Puts "The 2"
Afile. Close
# Part Two
What is jruby?
Jruby is a Ruby interpreter implemented in pure Java. Through jruby, you can directly run Ruby on JVMProgramTo call the Java class library. Many Ruby ides written in Java use jruby to explain the syntax.
Jruby, an open-source Ruby
Ruby processes strings like numbers. We enclose them with single quotation marks ('...') or double quotation marks.
Ruby> "ABC""ABC"Ruby> 'abc'"ABC"
Single quotation marks and double quotation marks have different functions in some cases. A
Now let's take the previous examples
Program Of
Code Let's take a look.
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
The new version of will_paginate has abandoned this practice and switched to the Gem method. This article builds an application named foobar to understand the usage of will_paginate.
====================================
C: \> rails foobar-D
1. send messages to the object
We can directly send messages to objects:
Ruby
Code
Copy code The Code is as follows: Class helloworld
Def say (name)
Print "hello,", name
End
End
HW = helloworld. New
HW. Send (: Say, "world ")
We usually use HW.
It can be divided into the following sections:
· Basic implementation
· Reference the original object in the iteration, or directly change the value of the array instead of returning a new array
· Input infinite parameters to Iteration
·
You may have noticed that in our previous code, the database definition uses an integer field id as the primary key, which is a convention of Active Record.
Maybe you have to ask, why don't we use order numbers or a meaningful column as the
The Ruby pp () function can be used to output arrays in a very beautiful way. However, the disadvantage is that the two-dimensional array is displayed on one row. We want it to be output in the form of a subarray per row, as shown in
Is it more
The String in Ruby is mutable, unlike the String in java and C # is immutable. For example
Copy codeThe Code is as follows: str1 = "abc"
Str2 = "abc"
In java, for literal strings, the jvm maintains a table internally. Therefore, in java, str1 and
Git repository outputGit archive -- format = tar -- prefix = actasfavor/HEAD | (cd/home/holin/work/& tar xf -)Output to the/home/holin/work/actasfavor/directory
Posted by holin At May 16,200 8Load controller and model in plugins
# Include hook code
To install Ruby, go to the Ruby official website to download the Windows Installation Package of Ruby1.56. After installing ruby, open the Dos window and enter Ruby-v to display it.Ruby 1.8.6 (patchlevel 0) [i386-mswin32] indicates that Ruby has
The String in Ruby is mutable, unlike the String in java and C # is immutable. For exampleCopy codeThe Code is as follows:Str1 = "abc"Str2 = "abc" In java, for literal strings, the jvm maintains a table internally. Therefore, in java, str1 and str2
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