Details

    • Type: Sub-task Sub-task
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None
    • Environment:
      mac 10.5.2 java.1.5 Groovy Version: 1.1-rc-2 JVM: 1.5.0_13-119
    • Number of attachments :
      0

      Description

      class CP implements Comparable
      {
      int number

      int compareTo(obj)

      { println 'compareTo called' return number - obj.number }

      boolean equals(obj)

      { println 'equals called' return obj.number = number }

      }

      // script
      def cp1 = new CP(number:1)
      def cp2 = new CP(number:2)
      cp1==cp2

      // results
      if CP implements Comparable, compareTo is called, if not, equals is called

      // using grails with above as follows has ominous implications

      I have a setup similar to as follows:
      TopLevelDomainClass

      { SortedSet subLevels static hasMany= [subLevels:SubLevelDomainClass] }

      SubLevelDomainClass implements Comparable
      {
      int number
      int compareTo(obj)

      { return this.number - obj.number }

      }

      sublevel1==sublevel2 calls the compareTo function for evaluation

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Brian White
          • Votes:
            5 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated: