From: "Jesús Gabriel y Galán" Date: 2010-11-12T22:27:06+09:00 Subject: Re: Ruby vs PHP for the web On Fri, Nov 12, 2010 at 1:54 PM, Josh Cheek wrote: > 2010/11/12 Jesús Gabriel y Galán > >> On Thu, Nov 11, 2010 at 11:50 PM, Mike Stephens >> wrote: >> > Charles Calvert wrote in post #960599: >> >>  Ruby uses >> >> strong, though dynamic, typing. >> > >> > Can you explain what you mean? That seems a contradiction in terms. >> >> http://en.wikipedia.org/wiki/Strong_typing >> >> It means that the language imposes restrictions about how different >> types are mixed, and avoids implicit conversions of types, among other >> things. Compare: >> >> Javascript (weak typing): >> >> 2 + '2' => '22' >> >> Ruby (strong typing): >> >> 2 + '2' => TypeError: String can't be coerced into Fixnum >> > > > Is Ruby strongly typed? > > 2 + 2.0 # => 4.0 > > Here it has implicitly converted the integer 2 to a float, in order to be > able to add them. You can even make your specific example pass, exactly as > written, by defining String#coerce: > > class String >  def coerce(num) >    return num.to_s , self >  end > end > > 2 + '2' # => "22" > I know that, but that's not an implicit conversion performed by the compiler, it's explicitly implemented in the classes. Citing from the above wikipedia article: The object-oriented programming languages Smalltalk, Ruby, Python, and Self are all "strongly typed" in the sense that typing errors are prevented at runtime and they do little implicit type conversion, Also, in Ruby, you cannot change the class of an object. Jesus.