The module in ruby is a bit similar to the namespace in. net. It can be used to distinguish the module with the same name but belongs to different developers (or organizations ).Code.
The following code defines an me module, in which SQRT is the
When using Ruby to output text to the console, Good coloring is necessary. The following describes how to output the colored text to the OS X terminal. In fact, it should also apply in Linux.
Originally, I only needed to post the link to the blog
1. Equal?
We often need to compare two objects. Ruby provides a variety of methods for comparing objects. We can use equal? The method is used to compare whether two objects are the same. This method is used to compare whether two values point to
ArticleDirectory
1.1 install Ruby
1.2 install rake and albacore
4.1, rakefile
4.2. Other functions provided by albacore
Microsoft tools are known for integration. automated building is generally based on Visual Studio or its
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
Modules and blocks are special in ruby.
The module has a namespace to organize classes, methods, and constants.Module also has the Mixin method. You can include a module in the class to implement the instance method mixed into a module.
Sample:
I just posted a few songs in the music space and typed a few Ruby words.
Code Popularity
Require
'
Net/HTTP
'
Count
=
1
..
100000
#
Define an array
Count. Each {
#
Each
|
Index
|
#
Element is
Ruby is very powerful. You can use the WIN32API module of the additional database DL/Win32 to directly call WIN32API
WIN32API. NewParameter 1 string Call DLL nameParameter 2 Name of the dllexport IN THE STRING DLLParameter 3 String Array
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Class
A
Def
SayPuts
"
I'm
"
EndEnd
Class
B
A
Def
Say
#
When super is added, it will not be overloaded and the subclass
"% 05d" % 123 the result is "00123""% 02x" % 10 returns "0a""% 03x" % 10 the result is "00a""% 010x" % 10 returns "000000000a" (9 prefixes 0)"% 10x" % 10 returns "a" (with a prefix of 9 spaces)
We can see that the first digit is the prefix,
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
Ruby on Rails is a Web application that enables you to develop, deploy, and maintain
ProgramA simple framework.
Of course, all web frameworks share the same goal. What makes rails so different? We can answer this question in several ways.
First,
In common: it is used for screen output.
Differences:After puts outputs the content, it will automatically wrap the text (if the content parameter is blank, only one line feed is output). If the content parameter contains an escape character, the
Class variables and class methodsFor a long time, all classes we created contain instance variables and instance methods: variables and methods associated with a specific class instance.Sometimes, classes also need to have their own States. So there
Ruby provides a powerful Inheritance Mechanism, and there are many inheritance methods. The simplest is"
Module Foo def Foo puts 'heyyyyoooo! 'Endclass Bar include fooendbar. New. Foo # heyyyyoooo! Bar. Foo # nomethoderror: Undefined method 'foo'
A running
Program An unexpected problem occurs. A file to be read does not exist. When you want to store some data, the disk is full. You may enter inappropriate data.
Ruby> file = open ("some_file ")Err: (eval): 1: In 'open': no such file or
Learning more than one programming languages, perferable extends different style ones, like scripting, object-oriented, functional, logic, etc. Learning Languages teaches you need about programming.
Read Good bools, for example, "pragmatic
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