From: Paul Brannan Date: 2001-08-25T01:42:06+09:00 Subject: [ruby-talk:20302] Re: another new toy On Sat, 25 Aug 2001, ts wrote: > ./b.rb:6:in `new': can't use new for this class (RuntimeError) > from ./b.rb:24 > pigeon% > > > I've not yet found an use for this stupid toy :-))) > > > Guy Decoux Well, one use would be so that you could have a class that only has static functions, but cannot be mixed in (since it is a Class and not a Module). This (arguably) gives you a slightly safer form of namespace. Another use would be to "hide" the fact that a particular class can be instantiated; instead of raising an exception in all cases, only raise an exception when the caller passes a binding as an argument that does not match an authorized "friend" class: class Foo private_class_method :new def self.create(b, *args) other = eval("self", b) raise "Unauthorized access to create" if not Bar === other return new(*args) end def foo return "foo" end end class Bar def bar puts Foo.create(binding).foo end end b = Bar.new b.bar puts Foo.create(binding).foo This produces: foo friend.rb:6:in `create': Unauthorized access to create (RuntimeError) from friend.rb:23 And could be a mixin just as you suggested before. Paul