Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-8
-
None
-
tested on Win2k
Description
just try
print(5+[1,2])
it results in null. I think that's nothing you would expect. But may be it's not a good idea to just make a new list [5,1,2]. So I suggest to throw an UnsupportedOperationException. This should always be the case when no operation is found, but as I'm new to the code of groovy and I didn't found the correct place to do this I will give only a fix for this special case:
Index: groovy-core/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
===================================================================
RCS file: /home/projects/groovy/scm/groovy/groovy-core/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java,v
retrieving revision 1.122
diff -u -r1.122 DefaultGroovyMethods.java
— groovy-core/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java 5 Oct 2004 08:53:38 -0000 1.122
+++ groovy-core/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java 4 Nov 2004 14:38:23 -0000
@@ -1719,6 +1719,20 @@
return answer;
}
+
+ /**
+ * Catch the unwanted case an Object and a Collection with the Collection on
+ * the right side.
+ *
+ * @param left an object
+ * @param right a Collection
+ * @return nothing
+ * @throws always an UnsupportedOperationException
+ */
+ public static List plus(Object left, Collection right)
+
/**
- Create a List composed of the same elements repeated a certain number of times.
*