[Training Video - 4] [Groovy] Function in detail
Employee.log=log Employee e1 = new Employee()
Employee e2 = new Employee()
e1.name = "A"
e1.salary = 100 e2.name = "B"
e2.salary = 200 e1.printName()
e2.printName()
def newSalary = e1.increaseSalary(100)
log.info "New salary of A is $newSalary"
e2.increaseSalary(100) log.info "Salary of $e1.name is $e1.salary"
log.info "Salary of $e2.name is $e2.salary" class Employee {
def static log
def name
def salary public void printName(){
log.info name
} public int increaseSalary(amt){
salary = salary+amt
return salary
}
}
Run Result:
Tue Oct 06 19:24:47 CST 2015:INFO:A
Tue Oct 06 19:24:47 CST 2015:INFO:B
Tue Oct 06 19:24:47 CST 2015:INFO:New salary of A is 200
Tue Oct 06 19:24:47 CST 2015:INFO:Salary of A is 200
Tue Oct 06 19:24:47 CST 2015:INFO:Salary of B is 300
[Training Video - 4] [Groovy] Function in detail的更多相关文章
- [Training Video - 3] [Groovy in Detail] Non-static and Static functions, initializing log inside class
log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...
- [Training Video - 3] [Groovy in Detail] Non-static and Static variables, objects and object referances
log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...
- [Training Video - 3] [Groovy in Detail] What is a groovy class ?
log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...
- [Training Video - 2] [Groovy Introduction]
Building test suites, Test cases and Test steps in SOAP UI Levels : test step level test case level ...
- [Training Video - 4] [Groovy] Optional parameter in groovy
Employee.log=log Employee e1 = new Employee() log.info e1.add(1,2,3,4) // optional parameters in gro ...
- [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 ...
- [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 ...
- [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" ...
- [Training Video - 4] [Groovy] String Functions
def x="I like to read books before bed" def temp = x.split(" ") log.info "S ...
随机推荐
- [转][Java]语法规范
先来个 阿里的 Java 开发手册(2017.5.20 发布 v1.2.0 .pdf) 本文来自:http://blog.csdn.net/sinat_27115575/article/details ...
- 模拟admin组件自己开发stark组件之搜索和批量操作
搜索相关,搜索的本质就是从数据库查询出来的数据过滤 用户自定义给出过滤条件joker.py list_display = ('id','title','price',) show_add_btn = ...
- 2017百度之星初赛B-1002(HDU-6115)
一.思路 这题“看似”比较难搞的一点是,一个节点上有多个办公室,这怎么求?其他的,求树中任意两个节点的距离(注意:没有最远或最最进这一说法,因为树上任意两个节点之间有且仅有一条路径.不然就有回路了,对 ...
- 如何用xMind打开.mmap文件
首先右键单击mmap格式文档,选择“属性” > “更改了打开方式” > 选择使用Xmind软件打开.然后双击mmap格式文档,就可以用Xmind打开了!
- Springmvc ajax请求400
转载做记录 传JSON对象 前端 function test () { var param = {username : "yitop"}; $.ajax({ timeout : 2 ...
- python开发_function annotations
在看python的API的时候,发现了一个有趣的东东,即:python的方法(函数)注解(Function Annotation) 原文: 4.7.7. Function Annotations Fu ...
- 24_java之转换流和缓冲流
01转换流概述 * A: 转换流概述 * a: 转换流概述 * OutputStreamWriter 是字符流通向字节流的桥梁:可使用指定的字符编码表,将要写入流中的字符编码成字节 * 将字符串按照指 ...
- Oracle导出CSV文件
-- 建立存储过程 CREATE OR REPLACE PROCEDURE SQL_TO_CSV ( P_QUERY IN VARCHAR2, -- PLSQL文 P_DIR IN VARCHAR2, ...
- 基于七牛Python SDK写的一个批量下载脚本
前言 上一篇基于七牛Python SDK写的一个同步脚本所写的脚本只支持上传,不支持文件下载. 虽然这个需求不太强烈,但有可能有人(在备份.迁移时)需要,而官方有没提供对应的工具,所以我就把这个功能也 ...
- MyBatis 学习记录3 MapperMethod类
主题 之前学习了一下MapperProxy的生产过程,自定义Mapper类的对象是通过动态代理生产的,调用自定义方法的时候实际上是调用了MapperMethod的execute方法:mapperMet ...