machineInitialization completeStart the environment execution vagrant Halt shutdown environment by executing vagrant up in the appropriate directory when usedOther points of attentionAfter successful initialization, a configuration file named Vagrantfile is generated in the appropriate directory, which can be set for network, memory size, and other content.This article is from the "7692323" blog, please be sure to keep this source http://7702323.blog.51cto.com/7692323/1596334Build a
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 passed"End=> "3 yards on the run"=> "7 yards passed"=> "Touchdown! "
It mainly refers to the use of array in block
Retrieve elements from arrayCopy codeThe Code i
Example of the use of hundreds of semicolons and literal values in Ruby: ruby percent
Use % () (abbreviated as % Q) for a single line string that requires interpolation and embedding double quotation marks ). Multi-line string, preferably heredocs.
# bad (no interpolation needed) %(
Do not use % q for strings without 'and. Unless many characters need to be escaped, the normal string is more readable.
download and have officially recommended documents, learning resources, andCommunity, Mail list, user group, Ruby defect tracking, Ruby openSource codeContribution and so on. You can say that everything about Ruby is available.
2. Ruby online documentation: http://ruby-do
GitHub advocates a summary of Ruby coding styles, while github advocates ruby code.
Source code layout: 1. All source files are UTF-8 encoded2. indent with two spaces3. Use Unix-style line breaks (\ n) and windows (\ r \ n ). You can use git config -- global core. autocrlf true to prevent the generation of windows-style line breaks.4. After ',', ';', add spaces before and after the operator (except for expo
Common Ruby file operation code instances and ruby code instances
# Create a 222. rb file and the input character File = file. open ("222.rb"," w + ") file. puts "123 \ nwadwa \ n12124124 \ ndwdw" file. close # output 222. rb content File. open ("222.rb"," r + ") do | file | while line = file. getsputs lineendend # directly use IO to operate the file IO. foreach ("222.rb") do | line | puts line if line = ~
Ruby-implemented file self-deletion code sharing, ruby-implemented code sharing
Because the File Deletion mechanism in windows is different from that in unix like, so does not guarantee that the following code can be used in windows. Which of the following kids shoes can help me test it in windows!
Copy codeThe Code is as follows:#! /Usr/bin/ruby
5. times do |
1. Auxiliary methods2. StringEnter "IRB" into the ruby command-line development environment, and the controller starts by executing "rails console" on the command line.(1) String connection>>"foo"+"bar"="foobar" (2) Interpolation by special syntax #{}>>first_name="Amy" ="Amy">>" #{first_name} Sun"+"Amy Sun "(3) The difference between a single-quote string and a double-quote string: Single-quote strings they really are literal values, contain only the
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
#
Create the object
Def
Initialize (names
=
"
World
"
)@ Names
=
NamesEnd
#
Say hi
entities are destroyed Delete_all: All associated entities are deleted directly from the database, unrecoverable nullify: foreign keys are Set to NULL, unrecoverable restrict_with_exception: Throw exception hint Restrict_with_error: Throw error prompt 5, Foreign_key: Define column name for foreign Key 6, inverse_of : Indicates the inverse associated entity 7, Primary_key: Indicates the associated item ID 8, through: Indicates that a many-to-many relationship uses a third-party entity 9, validat
Explain the code block object Proc in Ruby, and explain the ruby object proc.
Proc object
Proc is a block conversion object. There are four methods to create a Proc:
Sample Code
# Method 1 inc = Proc. new {| x + 1} inc. call (2) #=> 3 # method 2 inc = lambda {| x + 1} inc. call (2) #=> 3 # method 3 inc =-> (x) {x + 1} inc. call (2) #=> 3 # Method 4 inc = proc {| x + 1} inc. call (2) # => 3
In addition to th
Various sorting algorithms implemented by Ruby and Ruby
Time Complexity: Average (n ^ 2)
Bubble sortCopy codeThe Code is as follows:Def bubble_sort ()(A. size-2). downto (0) do | I |(0.. I). each do | j |A [j], a [j + 1] = a [j + 1], a [j] if a [j]> a [j + 1]EndEndReturnEnd
Selection sortCopy codeThe Code is as follows:Def selection_sort ()B = []A. size. times do | I |Min = a. minB A. delete_at (a. index (m
Class methods and class extensions in Ruby object-oriented programming, ruby Object-Oriented Programming
Class Method
The essence of a class method is a single-piece method that lives in a single-piece class of this class. Three methods are defined:
# Method 1 def MyClass. a_class_method; end # method 2 class MyClass def self. anther_class_method; endend # method 3 * class MyClass class
The third method in
Ruby-based optimal binary search tree algorithm and ruby-based optimal binary search algorithm
The pseudo code in the introduction to algorithms is rewritten, plus the constructor for the solution of the first question in the Introduction Class Exercises.Copy codeThe Code is as follows:# Encoding: UTF-8= BeginAuthor: xu jinDate: Nov 11,201 2Optimal Binary Search TreeTo find by using EditDistance algorithmRe
Comparison of class variables and instance variables in Ruby, ruby class variable instances
1. The class variable name starts with @. A Class variable is shared by all instance objects of the class. The instance variable name starts with @, and each instance object has its own different instance variables;
2. class variables must be initialized before use; otherwise, an error is reported during use. If the
Summary of loop statements in ruby and summary of ruby loop statements
While (when ...) Loop
While Condition Statement 1; Statement 2; statement... End
Single Row while LOOP
(Statement 1; Statement 2; statement... ) While Condition
Until (...) Loop
Until condition = while not (condition)
For... In Loop
For variable in obj
! Preview· the development trend of language must be the combination of static and dynamic, flexible and economic· Perl is obscure, Python is elegant and clear, Ruby is smart, and PHP is simple· Perhaps elegance comes from the attention to detail and norms.· RoR with Ruby, it's like a Nao with a cat, and instantly brings out Java and the. NET Elephant Figure? Questions
What are the characterist
Ruby is a powerful object-oriented scripting language that allows you to quickly and easily object-oriented programming. Sometimes it's a little "fuss" to develop small projects using formal object-oriented languages such as Smalltalk, Eiffel, or C + +. And Ruby just meets the needs of these object-oriented programming. Of course, you can also use Ruby for genera
extension to different pools for different sites), and th e ability to execute as a wildcard mapping, the only processes files, does not exist on disk. More information at all of these later.Ten) you are done!At here, you should is up and running. Hit up http://localhost:81/test/about, and you should get the RoR response from our test controller.Please try the your real RoR apps, and let me know how it went/what issues your hit. Your feedback would be instrumental on getting to a production qua
Basic Ruby tutorial,
1. Basic Ruby knowledge
1. Ruby
Ruby is a scripting language
Ruby is an object-oriented language
Ruby is a cross-platform language
Ruby is open source software.
2.
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.