Professional Web Applications Themes

equal? vs eql? vs == - Ruby

I'm working on writing a set of classes that implement weak versions of Hash, Array, and other classes that make sense. In doing so, I see there are four different methods that provide equality. Object#eql? Object#=== Object#== Object#equal? I understand why #eql? and #=== are separate from the others, but I don't quite understand why there are both #== and #equal? are they testing for different kinds of equality? Thanks, Samuel...

  1. #1

    Default equal? vs eql? vs ==

    I'm working on writing a set of classes that implement weak versions of Hash,
    Array, and other classes that make sense. In doing so, I see there are four
    different methods that provide equality.

    Object#eql?
    Object#===
    Object#==
    Object#equal?

    I understand why #eql? and #=== are separate from the others, but I don't quite
    understand why there are both #== and #equal? are they testing for different
    kinds of equality?

    Thanks,
    Samuel
    Samuel Guest

  2. #2

    Default Re: equal? vs eql? vs ==

    il Fri, 26 Dec 2003 20:44:08 -0600, Samuel Tesla
    <com> ha scritto::

     


    ri is you friend ;)



    obj.equal?( anObject ) -> true or false
    ------------------------------------------------------------------------
    Returns true if obj and anObject have the same object ID. This
    method should not be overridden by subclasses.

    obj == anObject -> true or false
    ------------------------------------------------------------------------
    Equality---At the Object level, == returns true only if obj and
    anObject are the same object. Typically, this method is
    overridden in descendent classes to provide class-specific
    meaning.


    gabriele Guest

  3. #3

    Default Re: equal? vs eql? vs ==

    gabriele renzi <yahoo.it> writes:
     

    You know, I read that. For some reason I did not register the word "not" in
    the second sentence.

    Thanks.

    -- Samuel
    Samuel Guest

Similar Threads

  1. Are equal all ssa cables ?
    By jose in forum AIX
    Replies: 6
    Last Post: November 26th, 12:51 AM
  2. Opposite but equal?
    By Giacomo in forum Microsoft SQL / MS SQL Server
    Replies: 6
    Last Post: July 19th, 06:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139