Yochen Gutmann wrote:
> Does Duck-Typing mean "ah, the programmer always knows, which kind of 
> objects this method expects. Thus never an error will occur."? This 
> seems very optimistic to me if not naiv. You cant just trust that the 
> any programmer who uses your class knows what exactly is happening in 
> your method and which type of object is required.

No, duck typing means you just use those methods needed and if the type 
doesn't match the caller gets bitten by an exception.  You should of 
course document what the method does.  For example (silly method)

# appends using "<<"
def append(s,x) s << x end

can be invoked with a String or IO or Array etc. as first parameter. 
But if you pass nil you'll see an exception.

Type checks are done rather rarely.  The other way to do is what Daniel 
showed (a lot core classes do this AFAIK).

Kind regards

	robert