Ruby entry-level authoritative classics (2)

Source: Internet
Author: User
Chapter 2 Ruby Data Types
    1. Number: If fixnum is out of the range, it is automatically converted to bignum. Numeric is the base class for all numeric types, float and integer are the subclasses of numeric, and fixnum and bignum are the sub-types of integer. An integer can be of any length. In a certain range, you can add a question mark before an ASCII character or an escape character to obtain its numerical value.
    2. String: the ruby string is a simple 8-bit byte sequence. You can use # {expression} to insert the values of any Ruby expressions into the string, if the expression is a global variable, a class variable, or an instance variable, braces can be omitted. You can use % Q, % Q to construct a string, which is useful when constructing a long string. % Q and % Q are used to define the range of single quotes and double quotes.
    3. Common Methods for string: the string class contains a large number of standard methods. Among the many methods in this class, the names at the end of these methods are! Will directly modify the content of the string, so use! The method is safer.

(1) *: returns the new string after repeating the specified number of times.

(2) [] Symbol: A [nth] returns the content of the nth byte in the form of an integer. If nth is a negative value, it is counted from the end of the string, if nth exceeds the range, Nil is returned. A [nth, Len]: returns a substring of len bytes counted from nth bytes. If nth is negative, it is counted from the end of the string.

(3) Next, next !, Succ and succ! These four methods are used to return the next string.

Question: Next, next !, Succ and succ! Is not very familiar with the usage.

(4) [substr]: If the string contains substr, a consistent string is generated and returned. If the string does not contain substr, Nil is returned.

(5) [Regexp]: returns the substring that initially matches Regexp. Information related to the matching operation is saved to the internal variable $ ~ . [Regexp, Nth]: If the nth parameter is used, the first substring that matches the nth parentheses in Regexp is returned.

Chapter 2 desktop application and web development

1. eruby is a technology. RubyCodeEmbedded in the page to build a web application. Ruby is similar to Java, Ruby CGI is similar to servlet, eruby is similar to JSP, and rails is similar to struts. There are multiple methods for implementing embedded Ruby script execution, and the most widely used one is "eruby ". Note: eruby is a technology, while eruby is an implementation.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.