git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
17 lines
342 B
Ruby
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
|
|
|