Name
Local Variables
Synopsis
foo
Local variables begin with a
lowercase letter or _
. The scope of a local
variable ranges from class
,
module
, def
, or
do
to the corresponding end
or
from a block’s opening brace to its close brace
{}
. The scope introduced by a block allows it to
reference local variables outside the block, but scopes introduced by
others don’t. When an uninitialized local variable is
referenced, it is interpreted as a call to a method that has no
arguments.
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.