Tutorial on system management by writing scripts in Ruby, and ruby System Management
Introduction
Ruby is an extremely rich, free, simple, scalable, portable, and object-oriented scripting language. Recently, it is widely used in the Web field. To a
Brief introduction
Ruby is an extremely rich, free, simple, extensible, portable, object-oriented scripting language. Recently, it has been widely popular in the Web field. This is partly due to the very powerful WEB application development
Array
1. To create an array:
As with many other programming languages, it is easy to create an array, but note that Ruby is a weak type of scripting language in which the types of elements in an array can be different and the length of the array
Chapter 2 Structure and running of Ruby programs
The ruby annotation starts with # And ends until the end of the line. Ruby does not have/*... */C style annotations.
If # appears in the string or regular expression literal, it is a part of a
Iterators are methods that are supported by collections. An object that stores a set of data members is called a collection. In Ruby, arrays and hashes can be called collections.
The iterator returns all the elements of the collection, one after
A summary of the basic operation methods of the Hash structure in Ruby, rubyhash
About hashFirst, let's take a look at the basic ideas of Hash:If the number of objects to be stored is num, we will use len memory units to store them (len> = num). The
Summary of basic operation methods for Hash types in Ruby, rubyhash
1. Create a hash:Just like creating an array, we can create a Hash instance using the Hash class:
H1 = Hash. new # default value: nilh2 = Hash. new ("This is my first hash instance")
About hashingLet's take a look at the basic idea of hashing:To set the number of objects to be stored in NUM, then we use Len Memory units to store them (len>=num); With the keyword of each object ki as the independent variable, a function h (KI) is
Create a new class and use the Dom. Factory method. Obviously, it is a factory method that produces various classes in batch.
VaR myfirstclass = Dom. factory ({message: "Hello World", sayhello: function () {alert (this. message) ;}}); var OBJ =
1. Create a hash: just like creating an array, we can create a hash instance from the hash class:
H1 = hash.new #默认值为nil
h2 = Hash.new ("This is the My-my-a-hash instance") #默认值为 "This is me-a-my-a-hash instance":
The above
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.