Ruby/Language Basics/Global Variables

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

define global variables by putting a dollar sign ($) in front of the variable name

def basic_method
  puts $x
end
$x = 10
basic_method



Global Variables

Global variables are available globally to a program. 
Their scope is the whole program. 
Global Variables are prefixed by a dollar sign ($).
$amount = "0.00"