swig/Examples/ruby/functor/runme.rb
Dave Beazley 12a43edc2d The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2002-11-30 22:01:28 +00:00

17 lines
342 B
Ruby

# Operator overloading example
require 'example'
a = Example::IntSum.new(0)
b = Example::DoubleSum.new(100.0)
# Use the objects. They should be callable just like a normal
# Ruby function.
(0..100).each do |i|
a.call(i) # note: function call
b.call(Math.sqrt(i)) # note: function call
end
puts a.result
puts b.result