Computer ScienceScience & MathematicsEconomics & FinanceBusiness & ManagementPolitics & GovernmentHistoryPhilosophy

Using Blocks in Ruby

A Brain-Friendly Report

by Jay McGavren

Using Blocks in Ruby

Subscribe to new books via dBooks.org telegram channel

Join
DescriptionTable of ContentsDetailsHashtagsReport an issue

Book Description

Unannounced and unmarked, blocks turn up all over Ruby programs. Their use ranges from some of Ruby's most basic structures, such as loops, to some of its most sophisticated tricks. Similar to closures or lambdas in other languages, blocks enable some of Ruby's vaunted efficiency. Blocks even allow other people to write some of the code you use.

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

This open book is licensed under a Creative Commons License (CC BY). You can download Using Blocks in Ruby ebook for free in PDF format (2.0 MB).

Table of Contents

Section 1
Blocks are mind-bending stuff. But stick with it!
Section 2
Defining a method that takes blocks
Section 3
Your first block
Section 4
Flow of control between a method and block
Section 5
Calling the same method with different blocks
Section 6
Calling a block multiple times
Section 7
Block parameters
Section 8
Using the "yield" keyword
Section 9
Block formats
Section 10
The "each" method, step-by-step
Section 11
DRYing up our code with "each" and blocks
Section 12
Blocks and variable scope
Section 13
Using "each" with the "refund" method
Section 14
Using "each" with our last method
Section 15
Our complete invoicing methods
Section 16
We've gotten rid of the repetitive loop code!
Section 17
Utilities and appliances, blocks and methods

Book Details

Title
Using Blocks in Ruby
Subject
Computer Science
Publisher
O'Reilly Media
Published
2017
Pages
25
Edition
1
Language
English
ISBN13 Digital
9781491969151
ISBN10 Digital
1491969156
PDF Size
2.0 MB
License
CC BY

Book Hashtags

Related Books

A Rust Sampler
Thread-safe, reliable, and lightning-fast, Rust has been the most loved programming language on Stack Overflow for four years and counting! This open source systems language gets its amazing speed in large part from its memory safety - and without resource-greedy garbage collection. Offering freedom from a runtime requirement, a rich type system, a...
Internet of Things
First IFIP International Cross-Domain Conference, IFIPIoT 2018, Held at the 24th IFIP World Computer Congress, WCC 2018, Poznan, Poland, September 18-19, 2018, Revised Selected Papers...
I Love Ruby
Ruby is an easy to learn programming language, it was invented by a guy named Matz in Japan. Ruby is a free software and can be used by any one for zero cost. Ruby's popularity was initially confined to Japan, later it slowly trickled out to rest of the world. Things changed with the emergence of Ruby on Rails which is a popular web-developmen...
Ruby Notes for Professionals
The Ruby Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow....
Learning Ruby on Rails
Ruby on Rails (RoR), or Rails, is an open-source popular web application framework. Rails uses Ruby, HTML, CSS, and JavaScript to create a web application that runs on a web server. Rails uses the model-view-controller (MVC) pattern and provides a fullstack of libraries from the database all the way to the view. It is an unofficial and free Ruby...
Preparing for Life in a Digital Age
Ability to use information and communication technologies (ICT) is an imperative for effective participation in today's digital age. Schools worldwide are responding to the need to provide young people with that ability. But how effective are they in this regard? The IEA International Computer and Information Literacy Study (ICILS) responded t...