Ruby Notes

Posted by : at

Category : Technical


Developer roadmap

Namming

  1. Global variables start with $
  2. Class variables start with @@
  3. Instance variables start with @
  4. Local variables must begin with a lowercase or an under score
  5. Constants start with an upper case letter

Ruby variablse names must begin with a lowercase letter or underscore, and many contain only letters, numbers, and underscore characters.

Variable names must not conflict with keywords (e.g. you cannot have variable called class), but unambiguous name that contain reserved worlds are acceptable (i.e. both classy and _class are valid Ruby variable names)

Variable

With instance variables, class variables or Global variables, we can use #$, #@ or #@@ to puts this values with string.

#{$x} ~ #$x
#{@x} ~ #@x
#{@@x} ~ #@@x

#{x} != #x => not working

About Hung Nguyen
Hung Nguyen

Hi I a Hung, a Web Developer and Project manager.

Email : hungnv950@gmail.com

Website : http://hungnv950.github.io

About Hung Nguyen

Hi, my name is Hung Nguyen

Star
Categories
Useful Links