Block variables are defined in the enclosing method's scope and can be accessed only in the current scope and nested scopes. A block variable can be declared as either public, private or protected. The public declaration makes it available to any nested blocks, private restricts access to just this block and protected restricts access to methods within its own class or its subclasses.
Block scoped variables: A block scoped variable is one that is only available from within the block. Even if a block is inside a function, a block scoped variable will not be available outside the block.
When a variable is declared inside a function, it can only be accessed within that function and cannot be utilised outside of it. When a variable is declared inside an if or switch condition or a for or while loop, it is only available within that condition or loop.
They can't stand on their own, unlike functions. A block is a piece of code that can be invoked in a similar way to a function, but not quite: it only occurs next to a function call like. each, and that function may or may not use that block by "invoking" it (executing the code inside it).
The main distinction is that method has a name, but block does not, and arguments to method are passed between brackets (), whereas arguments to block are passed between pipes ||. How to return values from a block: Actually, the value returned by the method on which it is called is returned by block.