On Wed, Oct 24, 2012 at 9:21 PM, 7stud -- <[email protected]> wrote:

> Todd B. wrote in post #1080981:
> >
> > Okay, I see, thanks.
> >
>
> Okay, you see what?  That was one of the worst responses I've ever read
> on this forum.  It completely missed the big picture.  Your example
> shows that ruby is a completely screwed up somewhere.  You can't have
> two constants with the same name, so your class should have overwritten
> the Struct.


Ruby is not screwed up, at least not in the ways you say it is. The `class
S` line isn't declaring a new class named S, it's reopening the class
created by Struct.new.

    S = Struct.new(:num)
    class S
      def show_num; puts "Show:#{self.num}"; end
    end

is like

    S = Struct.new(:num) do
      def show_num; puts "Show:#{self.num}"; end
    end

or similar enough to

    class S < Struct.new(:num)
      def show_num; puts "Show:#{self.num}"; end
    end

-- 
-yossef

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to