The first character of the Ruby variable name determines whether it is a local variable, an instance variable, a class variable, a global variable, or a constant. Typically, the second character of a variable name is a number, a letter, or an
1, with java,c# and other languages of the Try...catch...finally...throw, Ruby Begin/end ... rescue...ensure ... raise to handle the exception, retry can be used in rescue. You can use either rescue or ensure, when both are used, rescue must be in
Day 3Learning to enter the third day, today plans to learn modules, collections and Simple file operations.3.1Mixin ModuleObject-oriented languages use inheritance to propagate behavior to similar objects. Specific to the language, C + + uses a
Demand:To achieve a resume class, you must have a name, you can set the gender and age, you can set up work experience. Three resumes needed in the endInitial implementation:#-*-encoding:utf-8-*-#Resume ClassclassResume attr_accessor:name,: Sex,:
I won't go into any further discussions about symbol. I just want to talk about the advantages of it.
Each object in ruby is identified and distinguished by a digital ID. You can use XXX. object_id to view the ID.
Puts "0001". object_idputs "0001
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
When I started my ruby journey, I wrote my study notes for people with other OO language experiences. Let's take a look at the magic ruby.
The first sample! First meeting.
#
! /Usr/bin/ENV Ruby
Class
MegagreeterAttr_accessor: names
In RubyProgramYou will often see some variables starting with $. These are not the global variables we set in the program, but the variables that have been set inside the system, they represent some specific meanings. Some common internal variables
Development Environment
OS: Windows XP
RUBY: ruby1.8.7
Rails: rails2.3.5
MySQL: mysql5.0.9
IDE: rubymine2.0.1
Preparations:
Install the following gem package
Gem install ruport
Gem install ruport-util
Gem install acts_as_reportable
In this
# Code source: http://rubyer.me/blog/917. you can easily learn four kinds of closures of Ruby: blocks, procs, Lambdas, and methods.
# Firstclass array def iterate! Self. each_with_index do | N, I | self [I] = yield (n) end endendarray = [1, 2, 3, 4]
Use RVM to install ruby & rails in ubuntu
I have discussed how to install ruby in the source code mode in ubuntu. However, this method is always troublesome. You can use rvm for version management, and you can also use rvm for installation. linux
Tutorial on task build tool rake in Ruby, rubyrake
Rake Introduction
Rake indicates Ruby Make, a code building tool developed by ruby.
But why does Ruby need Rake?
It is reasonable to say that Ruby Code does not need to be compiled and Rake is not
Some Suggestions on Ruby on Rails routing configuration, rubyrails
When you need to add one or more actions to a RESTful Resource (do you really need it ?), Use member and collection routes.
# Differential get 'subscriptions/: id/unsubscribe
A few Ruby tips and Ruby tips
Sequential call of code blocksCopy codeThe Code is as follows:Def touch_downYield [3, 7]Puts "touchdown! "EndTouch_down do | (first_down, second_down) |Puts "# {first_down} yards on the run"Puts "# {second_down} yards
Explain the usage of loop statements in Ruby, and explain the usage of ruby statements.
The loop in Ruby is used to execute the same code block several times. This section describes all loop statements supported by Ruby in detail.Ruby while
Ruby: Case expression and rubycase expression
There are two forms of Ruby case expressions:
The first form is similar to a set of continuous if statements: it allows you to list a set of conditions and execute the first statement corresponding to
Interpreting the usage of annotations in Ruby and interpreting ruby annotations
The Code Annotated In the Ruby line is ignored at runtime. Single line comment # starts with the characters. They start from # To the end of the line as follows:
#!
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