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

Discussion in 'Ruby' started by Tom Counsell, Sep 12, 2004.

  1. Tom Counsell

    Tom Counsell Guest

    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
    Tom Counsell, Sep 12, 2004
    #1
    1. Advertising

  2. Tom Counsell

    ts Guest

    >>>>> "T" == Tom Counsell <> 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
    ts, Sep 12, 2004
    #2
    1. Advertising

  3. Tom Counsell

    Phlip Guest

    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/bin/view/Main/TestFirstUserInterfaces



    >
    > Thanks
    >
    > Tom
    >
    Phlip, Sep 12, 2004
    #3
  4. 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] } ] }] }
    Florian Frank, Sep 13, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. André
    Replies:
    3
    Views:
    1,563
  2. Rajarshi

    0 == False but [] != False?

    Rajarshi, May 24, 2007, in forum: Python
    Replies:
    20
    Views:
    691
    Erik Max Francis
    May 30, 2007
  3. DJ
    Replies:
    3
    Views:
    912
  4. trans.  (T. Onoma)
    Replies:
    0
    Views:
    143
    trans. (T. Onoma)
    Sep 25, 2004
  5. Intransition

    public_methods vs methods

    Intransition, May 5, 2010, in forum: Ruby
    Replies:
    0
    Views:
    85
    Intransition
    May 5, 2010
Loading...

Share This Page