Employee.log=log
Employee e1 = new Employee() log.info e1.add(1,2,3,4)
// optional parameters in groovy
log.info e1.add(2,3)
log.info e1.add(2,3,10) class Employee {
def static log public def add(a,b,c=3,d=10){
return a+b+c+d
}
}

Run result:

Tue Oct 06 19:31:50 CST 2015:INFO:10
Tue Oct 06 19:31:50 CST 2015:INFO:18
Tue Oct 06 19:31:50 CST 2015:INFO:25

[Training Video - 4] [Groovy] Optional parameter in groovy的更多相关文章

  1. Groovy轻松入门——搭建Groovy开发环境

    摘自: http://www.blogjava.net/BlueSUN/archive/2007/03/17/104391.html Groovy轻松入门--搭建Groovy开发环境 多日来,我发表了 ...

  2. Java 调用 groovy 脚本文件,groovy 访问 MongoDB

    groovy 访问 MongoDB 示例: shell.groovy package db import com.gmongo.GMongoClient import com.mongodb.Basi ...

  3. Groovy学习()Groovy是啥?

    Groovy是啥? groovy是英文中的一个单词,有marvelous.wonderful和excellen的意思. groovy是轻量级的,动态的,面向对象的,并且运行在JVM上的. groovy ...

  4. [Training Video - 2] [Groovy Introduction]

    Building test suites, Test cases and Test steps in SOAP UI Levels : test step level test case level ...

  5. [Training Video - 7] [Database connection] Various databases which are supported, Drivers for database connection, SQL Groovy API

    Various databases which are supported Drivers for database connection groovy.sql.Sql package SoapUI怎 ...

  6. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Exception Handling in groovy

    def x = new String[3] x[0] = "A" x[1] = "B" x[2] = "C" log.info"X ...

  7. [Training Video - 6] [File Reading] [Groovy] Reading Properties file

    Reading Properties file : Properties prop = new Properties() def path = "D:\\SoapUIStudy\\appli ...

  8. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] HashSet and Hashtable

    Hashset: HashSet set = new HashSet() set.add("India") set.add("USA") set.add(&qu ...

  9. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Array and ArrayList

    Array: def x = new String[5] x[0] = "India" x[1] = "USA" x[2] = "Korea" ...

随机推荐

  1. CMapStringToPtr添加与释放

    // 创建MapStringToPtr CMapStringToPtr m_prjFiles; CStringList m_fileList; m_fileList.AddTail(_T(" ...

  2. 通俗讲讲FPGA

    通俗讲讲什么是FPGA. FPGA出现之前,所有集成电路都可以看成雕塑家,但是雕成一个成品,往往要浪费很多半成品和原料,这就是ASIC的制造. 后来FPGA出现了,FPGA就是块橡皮泥,什么硬件电路都 ...

  3. Windows下搭建Nginx图片服务器

    在项目最开始,上传图片的时候,服务器先保存原图再使用ImageMagick生成上传图片缩略图,这种方法有很多缺点,例如生成的缩略图的大小是固定的,不能动态请求指定大小的缩略图. 虽然有非常多的图片云存 ...

  4. Java中 如何把Object类型强转成Map<String, String>类型

    首先你需要保证要转换的Object的实际类型是Map<String, String> 假设Object变量名为obj,强制转换(Map<String, String>)obj ...

  5. 【UVa】208 Firetruck(dfs)

    题目 题目     分析 一开始不信lrj的话,没判联通,果然T了. 没必要全部跑一遍判,只需要判断一下有没有点与n联通,邻接表不太好判,但无向图可以转换成去判n与什么联通. 关于为什么要判,还是因为 ...

  6. 生成短的uuid

    package test1; import java.util.Random; import java.util.UUID; public class ShareCodeUtil { private ...

  7. sql server 2008 链接到数据库引擎

  8. 恒大威武!关于SQL的一些基础知识整理回顾

    首先的首先,恒大威武! 开始正题. 关系代数: 目前主流的关系型数据库,是建立在关系代数的基础上的,即他的数学支撑是关系代数. 关系代数主要包括如下几个二目运算:并运算union.交运算interse ...

  9. .net Reactor之限定日期内使用,限定使用次数,限定使用时间

    .net Reactor之限定日期内使用,限定使用次数,限定使用时间 上一篇(https://www.cnblogs.com/s313139232/p/9908833.html)详细的记录了.net ...

  10. leetcode566

    public class Solution { public int[,] MatrixReshape(int[,] nums, int r, int c) { ); ); if (row * col ...