From: Gavin Sinclair Date: 2004-06-08T07:42:32+09:00 Subject: Re: How to ducktype a Hash? On Tuesday, June 8, 2004, 2:50:50 AM, Sean wrote: > On Monday 07 June 2004 07:35, Austin Ziegler wrote: >> >> Actually, Ruby has both types and classes. Many developers confuse >> types and classes because in C++ they are one and the same; in Java >> they are slightly different, but not noticeably so (with the >> introduction of interfaces). > Ruby has no types. All of Ruby's classes are described, and objects > instantiated, with an arbitrary set of methods and purpose. There is nothing > anywhere in Ruby to reflect on the purpose of a class. So are there types in Java, such that would fit the above description? What about C++ (no interfaces)? Other languages? FWIW, I think the concept of types in Ruby is wishy-washy. The sort of thing that humans can talk about but not computers. But the concept is still there. And ultimately, it's not that different in, say, Java, where (as you have pointed out) you can abuse an interface. So how can you reflect on the purpose of a class in Java? Or is it all a matter of degree? # In which case, Ruby's mixins are a drop-in replacement for # interfaces. # # Witness Amrita's mixin 'Amrita::ExpandByMember', which happens # to be a tag only. Gavin