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"
执行起来结果和介绍里面的不一样啊,请明白人给点解释。
----第一个
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"
本文深入探讨了Groovy编程语言的基础概念,通过具体实例展示了其特性和用法。同时针对用户遇到的问题提供了详细解释,帮助开发者更好地理解和运用Groovy。

被折叠的 条评论
为什么被折叠?



