|
Groovy example source code file (Groovy770_Bug.groovy)
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 |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
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.