1.def和in是关键字
2.==映射到了equals() 中,如果有Comparable接口实现,则优先compareTo
str1 = ‘hello‘ str2 = str1 str3 = new String(‘hello‘) str1 == str2 // true str1.is(str2) // true str1 == str3 // true str1.is(str3) // false
3.传递闭包
class Calibrator{ Calibrator(calcBlock){ print ‘using....‘ calcBlock() } } def calibrator = new Calibrator({ println ‘provider 1‘ }) def calcBlock2 = { println ‘provider 2‘ } def calibrator2 = new Calibrator(calcBlock2) /*output using....provider 1 using....provider 2 */
4.int[] arr = [1,2,3,4] // arr type is int[]
def arr = [1,2,3,4] // arr type is ArrayList
时间: 2024-10-12 12:43:12