1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[1] pry(main)> class MyClass
[1] pry(main)*   @@array = []
[1] pry(main)*   @@x = 0
[1] pry(main)*   def ajax_data
[1] pry(main)*     y = (rand() * 100).round()
[1] pry(main)*     @@array << [@@x, y]
[1] pry(main)*     @@x += 1
[1] pry(main)*   end  
[1] pry(main)* end  
=> nil
[2] pry(main)> mc = MyClass.new
=> #<MyClass:0x8557578>
[3] pry(main)> mc.ajax_data
=> 1
[4] pry(main)> mc.ajax_data
=> 2
[5] pry(main)> mc.ajax_data
=> 3
[6] pry(main)> mc.ajax_data
=> 4
[8] pry(main)> class MyClass
[8] pry(main)*   def self.get_array
[8] pry(main)*     @@array
[8] pry(main)*   end  
[8] pry(main)* end  
=> nil
[9] pry(main)> MyClass.get_array
=> [[0, 41], [1, 14], [2, 43], [3, 67]]