With this excerpt from Head First Ruby, you'll learn about blocks by looking at each concept from different angles. Exercises throughout will help you understand and remember how these closure-like structures work. In fact, these exercises are key component to our unique, hands-on Head First approach.
- Bend your mind around blocks and methods
- Build blocks into larger structures
- Do heavy lifting easily with blocks
- Get more done with less code
Table of contents
- Blocks are mind-bending stuff. But stick with it!
- Defining a method that takes blocks
- Your first block
- Flow of control between a method and block
- Calling the same method with different blocks
- Calling a block multiple times
- Block parameters
- Using the "yield" keyword
- Block formats
- The "each" method, step-by-step
- DRYing up our code with "each" and blocks
- Blocks and variable scope
- Using "each" with the "refund" method
- Using "each" with our last method
- Our complete invoicing methods
- We've gotten rid of the repetitive loop code!
- Utilities and appliances, blocks and methods
Pages : | 25 |
Size : | 2.0 MB |
Downloads: | 75 |
Created: | 2022-02-03 |
License: | CC BY |
Author(s): | Jay McGavren |
Warning: Trying to access array offset on false in /home/tutovnfz/public_html/amp/article-amp.php on line 263
Others related eBooks about Using Blocks in Ruby
Download free course Ruby on Rails Notes for Professionals, pdf file on 230 pages by Stack Overflow Community.
Ruby is an easy to learn programming language, it was invented by a guy named Matz in Japa..., download free Ruby tutorial in PDF (314 pages) created by Karthikeyan A K .
Download free course Learning Ruby on Rails, pdf file on 291 pages by Stack Overflow Community.
This book is a great collection of ideas, tricks, and skills that could be useful for Hack..., download free Ruby tutorial in PDF (281 pages) created by RubyFu .
This book written to provide clear and concise explanation of topics for programmers both starting to learn the Ruby programming language as well as those diving in more complex topics. Most examples are linked to online playground that allows you to change the code and re-run it.