1. Check whether the private method can be inherited.
Class A @ name = "anleb" def ask puts @ name end private: askenda =. new #. aska. send (: Ask) Class B
Conclusion: for private methods, class variables (similar to static variables,
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
• 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
Ruby is a dynamic scripting language that everyone knows.
The problem I want to discuss today is the exception handling mechanism in ruby.Code:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
1
I switched the development environment to Ubuntu last night. I felt the atmosphere. I used to develop it in Linux and then switched it to Windows for DOTNET development. Now we can see that Ubuntu has been upgraded to 7.04, which is a great
The full name of yarv is yet another Ruby Vm, which is another Ruby Virtual Machine implemented by Sasada Koichi.
At present, Ruby's virtual machine is completed through AST (Abstract syntax tree), which is slow and can only be used for pure script
Discuss and solicit opinions:
Cause :Ruby can greatly improve the efficiency of developers, but it takes a long time to learn it. Maybe a language cannot be perfect, but we need to make it as perfect as possible. To develop a plug-in system, you
Ruby processes single quotes and double quotes differently. (1) double quotation marks can be applied to escape characters (2) strings in double quotation marks can be replaced by # {varname}. For global variables or instance variables, the {}
When a method ends, we may need to clean it up. maybe an open file needs to be closed, and the data in the buffer zone should be cleared. if there is always only one exit point for each method, we can safely clean up our
CodePut it in one place and
The explanation is good. It should be clear a lot.
Ruby symbol details
Cause
Recently I have been studying Ruby on Rails. It is indeed an excellent database development framework. However, a large number of statements similar to the following are
Because the current Ruby does not support Unicode, Chinese-related processing has been vague in ruby, which is basically the path of their respective attempts. I also listed some ideas to help me sort out their own ideas.
Utf8 and Unicode
UTF is
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
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
If a model object has an attribute named balance, you can use the index operator to obtain the value of this attribute. You can use a string or tag. Here we use a tag, for example:
Account [: balance]#=>Get value
Account [: balance] = 0.0#=>Set
The JRuby community recently released the latest version of JRuby 1.6.5.
JRuby is a 100% pure Java implementation of the Ruby programming language. It integrates Ruby's concise syntax and a wide range of Java class libraries.
According to
Git repository outputGit archive -- format = tar -- prefix = actasfavor/HEAD | (cd/home/holin/work/& tar xf -)Output to the/home/holin/work/actasfavor/directoryPosted by holin At May 16,200 8Load controller and model in plugins# Include hook code
Let's write a function to calculate the factorial. The mathematical definition of the factorial is as follows:N! = 1 (when n = 0)= N * (n-1 )! (Other Cases)In Ruby, you can write as follows:Copy codeThe Code is as follows:Def fact (n)If n = 01ElseN *
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.