Ruby's Dynamic Features

Source: Internet
Author: User

I recently read the book Programming Ruby. I just got started with Ruby and joined the Rails framework. This is definitely the development of agile web development.

Ruby is a dynamic language mainly embodied in:

  1. You can directly use a variable without defining the type. The following code directly defines the variable name without the type declaration.
    Name = "Leo"
  2. The access control is not static. o (∩ _ ∩) o haha! I think this is amazing. Because the call of a method is dynamic, the method definition is searched during the call, and then its access controller is queried. If the access is restricted, an exception is thrown. Here I think static languages are all well done before. In terms of time, will Ruby consume more time for running because of searching? (Hope you can give me some advice)
  3. Block, which is a new concept introduced by Ruby. It is different from the code block or callback function that I used previously. The block definition is followed by a method and only appears together with the method call in the code. What is most dynamic is that the Code in a block is not executed immediately. Ruby will remember the context (local variables, current object, etc.) when the block appears and then execute the method call. Within the method, the block can be called by the yield statement like the method.

Ruby's magic stems from its dynamic characteristics.

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.