Ruby/Language Basics/Global Variables

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

Версия от 17:59, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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"