Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / ruby / functor / runme.rb
1 # Operator overloading example
2 require 'example'
3
4 a = Example::IntSum.new(0)
5 b = Example::DoubleSum.new(100.0)
6
7 # Use the objects.  They should be callable just like a normal
8 # Ruby function.
9
10 (0..100).each do |i|
11   a.call(i)              # note: function call
12   b.call(Math.sqrt(i))   # note: function call
13 end
14
15 puts a.result
16 puts b.result
17