Singleton methods and instance methods with same name? 
Author Message
 Singleton methods and instance methods with same name?

After a quick experiment I've confirmed that Ruby's OK with having class
(singleton) methods and instance methods with the same name, but is this
inherently evil?


Tue, 13 Apr 2004 22:46:09 GMT  
 Singleton methods and instance methods with same name?

L> After a quick experiment I've confirmed that Ruby's OK with having class
L> (singleton) methods and instance methods with the same name, but is this
L> inherently evil?

 Well, in this case ruby is evil :-)

 File::chown, File#chown, File::chmod, File#chmod, etc
 IO::readlines, IO#readlines, IO::read, IO#read
 Array::[], Array#[], Hash::[], Hash#[]
 Thread::abort_on_exception(=), Thread#abort_on_exception(=)
 Module::constants, Modules#constants

 etc

Guy Decoux



Tue, 13 Apr 2004 23:08:47 GMT  
 Singleton methods and instance methods with same name?

Quote:

> After a quick experiment I've confirmed that Ruby's OK with having class
> (singleton) methods and instance methods with the same name, but is this
> inherently evil?

please ask your church representative about this issue.

btw, try this:

        (Object.methods & Object.new.methods).length   #==> 38

________________________________________________________________
Mathieu Bouchard                   http://hostname.2y.net/~matju



Thu, 15 Apr 2004 04:09:53 GMT  
 Singleton methods and instance methods with same name?

Quote:


> > btw, try this:
> >       (Object.methods & Object.new.methods).length   #==> 38
> irb(main):001:0> (Object.methods & Object.new.methods).length
> 37

The conclusion is that no matter which class object you choose, many
methods are named the same in it and in all of its potential instances,
because of the inheritance of the Object class itself, and because Class
inherits from Object.

________________________________________________________________
Mathieu Bouchard                   http://hostname.2y.net/~matju



Fri, 16 Apr 2004 13:21:07 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Removing singleton methods and instance variables - how ?

2. Singleton method == Class method ??

3. accessing a instance method from a class method

4. Class methods vs Instance methods

5. Class method vs instance method???

6. Class method vs instance method???

7. same method as class and instance methods?

8. Class Methods (as opposed to Instance Methods)

9. IncrTcl: calling static methods vs instance methods

10. Object Tcl question - Class method and Instance method

11. Method to give name of class instance?

12. Name of a method of an instance

 

 
Powered by phpBB® Forum Software