[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: class arrays
From:       poseid <mulder.patrick () gmail ! com>
Date:       2010-05-18 14:15:08
Message-ID: f8ae8054-dc57-458a-98b1-bb83adc80927 () p17g2000vbe ! googlegroups ! com
[Download RAW message or body]

On 18 Mai, 16:00, MrZombie <mrzom...@thezombie.net> wrote:
>
> Erh, not that way. Sorry.
>
> You could have
>
> class A
>  @b = [1,2,3]
> end
>
> Which stores the array in a class-level instance variable.
>
> This other one
> class A
>  @@b = [1,2,3]
> end
>
> stores the array in a class variable.
>


Hm... ok, this is more or less what I expected as well, when reading
code employing instance/class variables. But how do I understand the
(old) code from a book on Rails:

class T < ActionView::Helpers::FormBuilder
  field_helpers.each do |s|
      src = <<-END_SRC
         def #{s}(field, options = {})
           @template.content_tag( ... )
         end
      END_SRC
  class_eval src, __FILE__, __LINE__
 end
end

To me it seems that field_helpers is an instance variable, but there
is no @ nor @@ used

thanks for feedback


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic