Changes

Understanding Ruby Variables

2 bytes added, 21:09, 30 November 2007
Ruby and Variable Dynamic Typing
Many languages such as Java and C use what is known as ''strong'' or ''static'' variable typing. This means that when you declare a variable in your application code you must define the variable type. For example if the variable is required to store an integer value, you must declare the variable as an integer type. With such languages, when a varaible has been declared as a particular type, the type cannot be changed.
Ruby, on the other hand, is a dynamically typed language. This has a couple of key advantages. Firstly it means that you do not need to declare a type when creating a variable. Instead, the Ruby interpreter looks at the type of value you are assigning to the variable and dynamically works out the variable type. Another advantage of this is that once a variable has bene been declared, you can dynamically change the variable type later in your scriptcode.
== Declaring a Variable ==