On Wed, 7 Feb 2001, Jim Freeze wrote:

> I have a question about some code in the pickaxe book on page 103:
>
> module Notes
>   attr :concertA
>   def tuning(amt)
>     @concertA = 440.0 + amt
>   end
> end
>
> class Trumpet
>   include Notes
>   def initialize(tune)
>     tuning(tune)
>     puts "Instance method returns #{concertA}"
>     puts "Instance variable is #{@concertA}"
>   end
> end

[...]
>
> I don't understand where the instance method 'concertA' is defined. I see
> that the instance variable '@concertA' is defined.
>
> Can someone please explain this to me.

On page 234 it says

  Class attribute declarations are technically not part of the Ruby
  language: they are simple methods defined in class Module that create
  accessor methods automatically.

so I think the attr: concertA is where it happens.

See also page 25 and 349 (assuming there's only one printing still...) or
the paragraph above the example on page 103.

Hpope this helps,

Mike

-- 
mike / stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok / colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA