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:
- You can directly use a variable without defining the type. The following code directly defines the variable name without the type declaration.
Name = "Leo"
- 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)
- 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.