On Jan 24, 2008 11:23 AM, Ronald Fischer <rofi / fusshuhn.de> wrote:
> I found in "Ruby Cookbook" (recipe 8.8) a syntactically
> interesting construct, which I would like to understand.
> Here is the excerpt from the coding example:
>
> require 'delegate'
> class OrdinalNumber < DelegateClass(Fixnum)
>   ...
> end
>
> I am a bit puzzled about the way the parent class is
> written: DelegateClass(Fixnum). This looks like a
> function call, only that DelegateClass is not a
> function (since it starts with an upper-case letter).
> How does it work out that DelegateClass(Fixnum) evaluates
> to something of type "Class"?

When in doubt check it out in irb:

  >> require 'delegate'
  => true
  >> DelegateClass(Fixnum)
  => #<Class:0x35dd9c>

So DelegateClass is indeed a function that returns a class and the <
syntax does allow expressions on the right hand side.

Brian.