#Ruby Interview Questions
Plain old english: Ways of grouping code we want to run.
The simplest explanation for a block is that it is a chunk of code between {}
or do...end
, that can't be stored in a variable and isn't an object.
A block is just part of the syntax of a method call. It doesn’t mean anything on a standalone basis and can only appear in argument lists.
The difference is subtle, but p prints the true value of an object, rather than a string-ified version of the object. This will make more sense soon, but for the sake of simplicity, we'll use the p command throughout the exercises, as we'll want to see the true values of our code returned to the output window.