1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
'A'
end
end
if rand() < 0.5
'B'
else
super
end
end
end
puts A.new.foo # => A
10.times do
puts B.new.foo # => prints 'B' 50% of the time
end
|
Pastie
Support Pastie
or read my
Pastie << self
blog
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
'A'
end
end
if rand() < 0.5
'B'
else
super
end
end
end
puts A.new.foo # => A
10.times do
puts B.new.foo # => prints 'B' 50% of the time
end
|