I want to be able to do calculations like
I tried this... It does not workCode:puts 10.toKilos; puts 10.2.toKilos
I can put a method definition in both class Fixnum and class Float to get this functionality. How do I use mixins to get the same functionalityCode:module Weights def toKilos self*2.2 end def toLbs self / 2.2 end end class Fixnums include Weights end class Float include Weights end puts 10.toKilos




Bookmarks