8 Glossary

Callable
An object that responsd to the call message. This also means the shorthand callable.() syntax can be used.
Function decorator
A function that takes a single lambda as an argument, and returns a lambda. A function decorator is a special type of higher order function.
Higher order function
A function that either takes a lambda as one of its arguments, or returns a lambda.
Laziness
Deferring computation until the results of the computation are needed.
Predicate
A function or method that always returns a boolean (true or false). Typically the name of a predicate method ends with a question mark, e.g. foo.nil?, bar.empty?.
Procable
An object that responds to the to_proc message, which should return an instance of Proc. Procables include instances of Proc, Method, and Symbol, and can be passed to a method as a block argument by prefixing with an ampersand. Procables are usually, but not necessarily, also Callable.
  1. It also leads to the question, what is programming?, which turns out to be surprisingly hard to answer well. We’ll assume that if you’re reading this book you have some sense of what programming means to you, which should be enough to cover, however loosely, the stuff we’ll be doing here.
  2. These are variables, but we will not stress that point, since if there is one thing we will try to avoid it is varying them. In other words, we will avoid assigning a new value to a variable that was already previously assigned.
  3. In Ruby (almost) everything is an object, and objects are values. So it seems we are generally covered.
  4. Or to be pedantic, a method, we’ll talk about the difference later in the book.
  5. What actually happens when you define a function in the “top level scope”, so outside of any module or class, is that it becomes a private method in the Kernel module. This module is included in all classes, so the method can effectively be called from anywhere, but you can only call it with an implicit self. So puts(3) will work, but self.puts(3) or foo.puts(3) will cause an error.
  6. Crazier things have happened. It’s these kind of things that make working with existing code a lot like spelunking The Dungeon Dimensions. Your assumptions about what is physically possible in the universe you inhabit are questioned, then pulverized, at every turn. In general when making a change that does not change existing behavior, make sure you have also thought about every single error condition that might occur. This includes gravity suddenly deciding it kinda fancies going the other way for a change.
  7. If you’re familiar with Unix pipes, then think of it as a pipe that works in the other direction. The last command gets executed first.