Ruby/Language Basics/Global Variables

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

(Различия между версиями)
Перейти к: навигация, поиск
м (1 версия: Импорт выборки материалов по Ruby)
 

Текущая версия на 17:59, 13 сентября 2010

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"