Ruby test

Ruby code posted
created at 07 Oct 00:21

Edit | Back
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
h = Hash[:key1, 'value1', :key2, 'value2']
h = {key1 : ‘value1’, key2 : ‘value2’}

a = Array.new(); a << 1; a << 2;
a = [0,2,3]

class SomeClass
   # ...
end

SomeClass = Class.new do
   # ...
end

class MyHash < Hash
   # ...
end

MyHash = Class.new(MyHash) do
   # ...
end


module SomeModule
  def some_method
  end
end

SomeModule = Module.new do
  def module_method
  end
end

class A
  def some_method(arg1, arg2)
    # ... doing some stuff
  end

  define_method(:some_method) do |arg1, arg2|
    # ... doing some stuff
  end
end
577 Bytes in 4 ms with coderay