From: dblack@... Date: 2002-09-24T03:11:55+09:00 Subject: Re: The problem with run-time type checking Hi -- On Tue, 24 Sep 2002, Brian Denny wrote: > String and Array are both of type Enumerable, and they both have a "length" They mix in Enumerable -- which isn't just a quibble about terminology: the whole mixin process pertains to interface-building rather than type. > method. however, the statement > > "String and Array both conform to an (unnamed) type 't', defined as the set > of those methods which both String and Array objects respond to" > > is false, IMO, because the semantics of "each_with_index" are not the same, > in relation to the semantics of "length", in class String as they are in > class Array. They aren't necessarily the same in class String and class String either :-) irb(main):039:0> t "hi" irb(main):040:0> t.type String irb(main):041:0> s "hi" irb(main):042:0> s.type String irb(main):043:0> t.each_with_index {|x| p x} ["hi", 0] nil irb(main):044:0> s.each_with_index {|x| p x} Hello The dynamic nature of Ruby objects is such that there's really no guarantee of what they do except... what they do. That's more of a starting point than an ending point, but I'm almost late for a class.... David -- David Alan Black | Register for RubyConf 2002! home: dblack@candle.superlink.net | November 1-3 work: blackdav@shu.edu | Seattle, WA, USA Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com