Pages

Thursday, December 23, 2010

Duck Typing

 Hi today learning duck typing
    It ca n support polimorphism ?
  ruby is a advancing of polimorphism and it can support ducktype
   and  today i learn learn converting numeric into symbol.
  Sample pgm

    numeric, number ...................
  
     number =gets.ti_i
str=''
unit=number%100
case
when unit=9 then str='ix'
when unit=5 then str='v'
when unit=4 then str='iv'
when unit<4 then unit.time{str=str+'i'}
when(unit>5andunit<9)then
begin
str='v'
(unit-5).times{str=str+'i'}
end
end
print str

No comments:

Post a Comment