[ create a new paste ] login | about

Link: http://codepad.org/ceiHUdM3    [ raw code | output | fork ]

Ruby, pasted on Jul 28:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/ruby

def skylab13
  # puts g     # -> Error because "g" is not global.
  puts @g   # needs "@" mark.
  g = 222
  puts g
end

g  = 111 # default as local
@g = 30  # instance variable needs "@" mark.
puts g, @g
skylab13()
puts g, @g


Output:
1
2
3
4
5
6
111
30
30
222
111
30


Create a new paste based on this one


Comments: