| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (Groovy770_Bug.groovy)

This example Groovy source code file (Groovy770_Bug.groovy) is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

comparable, cpair, cpair, groovy770_bug, groovy770_bug, groovytestcase, pair, pair, string, string, util

The Groovy Groovy770_Bug.groovy source code

 * @version $Revision: 2289 $

package groovy.bugs

class Groovy770_Bug extends GroovyTestCase {
    void testBug() {
        def a = new Pair(sym:"x")
        def b = new Pair(sym:"y")
        def c = new Pair(sym:"y")

        def l1 = [a, b]
        def l2 = [c]
        println (l1)
        println (l2)
        println (l1 - l2)
        assert l1 - l2 == l1

        a = new CPair(sym:"x")
        b = new CPair(sym:"y")
        c = new CPair(sym:"y")
        l1 = [a, b]
        l2 = [c]
        println (l1)
        println (l2)
        println (l1 - l2)
        assert l1 - l2 == [a]

import java.util.*

class Pair {
  String sym

class CPair implements Comparable {
  public String sym
  int compareTo(Object o) {
      return sym.compareTo(((CPair) o).sym);

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Groovy770_Bug.groovy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.