From: Moises Trovo Date: 2008-02-21T01:18:53+09:00 Subject: Re: Ruby type-safe? Ruby strongly/weakly typed? Ruby pitfalls? On Sun, Feb 17, 2008 at 7:59 PM, Rule.rule wrote: > On Feb 6, 7:56 am, Eivind Eklund wrote: > > On Feb 6, 2008 2:20 AM,rule.rule.r...@gmail.com > > > > > wrote: > > > Hi, > > > > > I added some paragraphs to theRubyarticle on Wikipedia: > > > > > Type system > > > - IsRubytype-safe? > > > - IsRubystrongly typed? > > > > > Def 8 seems to be wrong; you're looking at what a variable refers to, > > rather than the object type. The object type is constant throughout > > object lifetime inRuby(excepting some hacks that I think are > > C-based). > > > > Eivind. > > OK, I see what you mean... > So this might then be a better example of the type of an object > changing at runtime in Ruby... > > > x = 4 > > class Fixnum > def twice > to_i * 2 > end > end > > puts x.twice > > irb(main):001:0> 4.class => Fixnum irb(main):002:0> (4.to_i*2).class => Fixnum The type doesn't change in your example.