[Groovy] 问两个问题
groovy入门介绍里的例子,http://groovy.codehaus.org/JN0025-Starting
执行起来结果和介绍里面的不一样啊,请明白人给点解释。
----第一个
groovy> def abc= 4
groovy> def ABC= 4
groovy> println abc.class
groovy> println ABC.class
groovy> assert ! abc.is( ABC )
class java.lang.Integer
class java.lang.Integer
Exception thrown
Nov 14, 2011 5:06:41 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize
WARNING: Sanitizing stacktrace:
Assertion failed:
assert ! abc.is( ABC )
| | | |
| 4 | 4
false true
----第二个
groovy> def x= ['a', 'b', 'c'] as Integer[] //convert each item in list to an Integer
groovy> assert x[0] == 97 && x[1] == 98 && x[2] == 99 //access each element individually
Exception thrown
Nov 14, 2011 5:07:20 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize
WARNING: Sanitizing stacktrace:
java.lang.NumberFormatException: For input string: "a"