/trunk/Examples/ruby/functor/runme.rb
Ruby | 17 lines | 9 code | 5 blank | 3 comment | 0 complexity | a2d12520a37a807f3d7c6d2c403b1907 MD5 | raw file
1# Operator overloading example 2require 'example' 3 4a = Example::IntSum.new(0) 5b = 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 13end 14 15puts a.result 16puts b.result 17