Forum: Ruby Oops, my fault...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
82e62c756d89bc6fa0a0a2d7f2b1e617?d=identicon&s=25 rosco (Guest)
on 2005-11-28 18:19
(Received via mailing list)
Ahem, well, forget the third question. I'm blaming Eclipse's CVS
handling
- I thought the copy seemed a bit small. Hope I didn't waste anyone's
time
with that...

What I came up with for this (a better example):

     def blah_blah
       @sh = Object.new
       class << @sh
         require 'code_that_adds_new_Object_methods'

         def new_obj
           Object.new
         end

       end
       @sh
     end

[ The new methods get applied to @sh only ].

(Quoting me):
> I don't know, for example, what happens with objects instantiated in
> that 'scope' (or is this about namespaces?)if they get passed back to
> the main program? I'd guess the methods are retained, because that's
> what happens with the shobject, right? (I can call the file ops from
> IRB), but I've fallen into that trap before  If that's so, then what
> happensin case of a conflict?  How does it work, and are there (m)any
> gotchas to watch for?

Is that it doesn't work at all, apart from with Rake (like the previous
example). So I guess it must be something about the way require is used
in
Rake? I'd have to look into it a bit more I guess...
This topic is locked and can not be replied to.