Keyword meanings in ruby

Source: Internet
Author: User

1,BreakJump out of layer Loop

2,NextIgnore the remaining part of this loop and start the next loop

3,RedoStart the loop again, or start from this time

4,RetryStart the loop body again

5. $ array <value adds value to the array $ array as an element of the array

6,Attr_writer: Username is equivalent
Def username = (value)
Return @ username = Value
End

ATTR _ Reader: Username is equivalent
Def Username
Return @ username
End

7,Attr_accessor: Username is equivalentAttr_reader: Username;Attr_writer: Username

Similar to the getter and setter methods in Java

8,Sometimes "! ","? ",! It implies that this method is destructive and may change the input parameters ,? Indicates that this method is a Boolean method. Only true or false is returned.

9. Definition of Singleton method in ruby: First, you must generate an instance object, and then add the object name and a period before the method name ".",

For example, Def obj. Meth indicates that the method meth only belongs to the object obj.

10. Symbols used for inheritance in ruby<Indicates

11. Method scope in ruby: public protected private

The public and Java classes are the same.

The protected method can be accessed by defining its class and its subclass. It cannot be directly called by the Instance Object of the class and subclass, but can be specified to the instance object in the class and subclass;

Private method, which can be accessed by its class and its subclass. Private methods cannot specify objects.

In Ruby, both the private and protected methods can be inherited by the quilt class.

 

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.