From: Robert Klemme Date: 2008-04-09T06:10:32+09:00 Subject: Re: Method parameters Type On 08.04.2008 00:53, Phillip Gawlowski wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Avdi Grimm wrote: > | On Mon, Apr 7, 2008 at 5:12 PM, Phillip Gawlowski > | wrote: > |> Ruby is? > |> > |> Doesn't look like it to me, since I can change the type of a variable > |> with ease. > | > | You're confusing static typing and strong typing. > | > | In a weakly-typed language, like C, it is possible to cast an integer > | as a, for instance, a char*, and then call string functions like > | sprintf() on it and the compiler will compile it, the runtime will run > | it, and it will wreak whatever havoc you please. Most high-level > | languages are strongly-typed, these days - neither Java or Ruby will > | allow you to call a String method on an Integer. You can assign > | whatever object you want to a variable in Ruby - hence *dynamic* > | typing - but that object will only ever allow you to call supported > | methods on it; otherwise you'll get a NoMethodError. Hence *strong* > | typing. > | > > Thanks for the enlightenment. :) Another way to put it would be that Ruby's variables are type-less, while objects do have a specific type. While we're at it: type != class. Basically the type is defined by all operations (aka methods) usable on an instance - not the class it was created from. Kind regards robert