From: Dossy Date: 2002-10-06T00:42:38+09:00 Subject: Re: thoughts on typelessness On 2002.10.06, Ryan King wrote: > On 2002.10.01, Dave Thomas wrote: > > > def func (a) > > > raise "type error" unless a.kind_of? Fixnum > > > .... > > > > Ruby types are not releated to classes. They're related to object > > protocols (the infamous Duck Typing). That's what gives Ruby much of > > its appeal. Testing for classes is really very poor style, and > > artificially constrains the users of your code. > > I can see how type checks like the above would be restrictive, > but I can't find anything about "Duck Typing" on Google. "Duck Typing", AFAIK, is the idea that if it looks like a duck, if it quacks like a duck, if it walks like a duck ... then, it's probably a duck. If the object looks like a string, acts like a string, responds to the same methods that an object of type String responds to ... then, its type is that of a String or one that appears like a String. Read [ruby-talk:26803] and [ruby-talk:26814] ... -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)