PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Examples/ruby/operator/runme.rb

#
Ruby | 25 lines | 15 code | 7 blank | 3 comment | 0 complexity | efaeb24030336218118a6bde4206b10b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # Operator overloading example
  2. require 'example'
  3. include Example
  4. a = Complex.new(2, 3)
  5. b = Complex.new(-5, 10)
  6. puts "a = #{a}"
  7. puts "b = #{b}"
  8. c = a + b
  9. puts "c = #{c}"
  10. puts "a*b = #{a*b}"
  11. puts "a-c = #{a-c}"
  12. # This should invoke Complex's copy constructor
  13. e = Complex.new(a-c)
  14. e = a - c
  15. puts "e = #{e}"
  16. # Big expression
  17. f = ((a+b)*(c+b*e)) + (-a)
  18. puts "f = #{f}"