Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > What governs the order of methods returned by object.public_methods( false ) ?

Reply
Thread Tools

What governs the order of methods returned by object.public_methods( false ) ?

 
 
Tom Counsell
Guest
Posts: n/a
 
      09-12-2004
Hello

I was wondering if anyone can help me by explaining what governs the
order of methods returned by object.public_methods( false ) ?

class Test
def a
end
def b
end
def c
end
end

t = Test.new

t.public_methods( false ) # => ["a", "c", "b"]

.... so appears to be neither in the order defined, nor alphabetical and
not random either?

Thanks

Tom

 
Reply With Quote
 
 
 
 
ts
Guest
Posts: n/a
 
      09-12-2004
>>>>> "T" == Tom Counsell <(E-Mail Removed)> writes:

T> I was wondering if anyone can help me by explaining what governs the
T> order of methods returned by object.public_methods( false ) ?

methods are stored in an hash, where the key is the id of the method
name.


Guy Decoux






 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      09-12-2004
Tom Counsell wrote:

> t.public_methods( false ) # => ["a", "c", "b"]
>
> ... so appears to be neither in the order defined, nor alphabetical and
> not random either?


To supplement the other answer:

def doc(anObject)
puts(anObject.class.name)

itsMethods = anObject.public_methods() -
Object.new().public_methods()

puts(itsMethods.sort()) if !itsMethods.nil?
end

I use that for a manual version of "intellisense", those annoying popups
that some editors use to tell you what to type next.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces



>
> Thanks
>
> Tom
>



 
Reply With Quote
 
Florian Frank
Guest
Posts: n/a
 
      09-13-2004
On 2004-09-12 22:24:58 +0900, Phlip wrote:
> I use that for a manual version of "intellisense", those annoying popups
> that some editors use to tell you what to type next.


If you are using this in irb, require 'irb/completion' and hit the
<TAB> key after your method dots.

--
lambda { |c| lambda { |f| f[f] } [ lambda { |f| c[lambda { |x| f[f][x] } ] }] }


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
CustomValidator Returns False, but False is Ignored DJ ASP .Net 3 12-27-2007 10:29 AM
0 == False but [] != False? Rajarshi Python 20 05-29-2007 11:04 PM
debug="false" in web.config and <%@ debug="true" ...%> in aspx file => true or false? André ASP .Net 3 08-28-2006 12:02 PM
False positive, false intrusion, false alarm Nick Computer Security 3 04-26-2006 07:40 PM



Advertisments