[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()
Planet p2 = new Planet()
Planet p3 = new Planet() p1.name = "earth"
p1.shape = "circle" p2.name = "jupiter"
p2.shape = "circle" p3.name = "mars"
p3.shape = "circle" log.info p1.name+" "+p1.shape
log.info p2.name+" "+p2.shape
log.info p3.name+" "+p3.shape p1 = p2
log.info "*************************************"
log.info p1.name+" "+p1.shape
log.info p2.name+" "+p2.shape
log.info p3.name+" "+p3.shape p1.name = "pluto"
log.info "*************************************"
log.info p1.name+" "+p1.shape //pluto
log.info p2.name+" "+p2.shape //pluto
log.info p3.name+" "+p3.shape class Planet{
def name
def shape
}
运行结果:
Tue Oct 06 20:41:45 CST 2015:INFO:starting
Tue Oct 06 20:41:45 CST 2015:INFO:earth circle
Tue Oct 06 20:41:45 CST 2015:INFO:jupiter circle
Tue Oct 06 20:41:45 CST 2015:INFO:mars circle
Tue Oct 06 20:41:45 CST 2015:INFO:*************************************
Tue Oct 06 20:41:45 CST 2015:INFO:jupiter circle
Tue Oct 06 20:41:45 CST 2015:INFO:jupiter circle
Tue Oct 06 20:41:45 CST 2015:INFO:mars circle
Tue Oct 06 20:41:45 CST 2015:INFO:*************************************
Tue Oct 06 20:41:45 CST 2015:INFO:pluto circle
Tue Oct 06 20:41:45 CST 2015:INFO:pluto circle
Tue Oct 06 20:41:45 CST 2015:INFO:mars circle
[Training Video - 3] [Groovy in Detail] What is a groovy class ?的更多相关文章
- Groovy学习:第四章 Groovy特性深入
作者:chszs 1. 断言 Java开发者常常使用JUnit或TestNG做单元测试,所以对断言是很清楚的.断言是用于验证假设的条件是否为真.在Groovy的断言中,如果假设的条件不为真,那么就会抛 ...
- Groovy学习:第三章 Groovy开发环境
本章将继续深入Groovy语言,首先学习Groovy脚本,包括从命令行编译和运行Groovy脚本,Groovy Shell,和Groovy Console.你将学会使用Groovy语言来建立域对象.控 ...
- [Training Video - 4] [Groovy] Function in detail
Employee.log=log Employee e1 = new Employee() Employee e2 = new Employee() e1.name = "A" e ...
- [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 - 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 - 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怎 ...
- [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 ...
随机推荐
- mac下的virtualbox启动失败处理
不知从哪个版本开始,mac下的virtualbox建立vm以后,启动就提示什么驱动没有加载,google后,解决如下 sudo /Library/Application\ Support/Virtua ...
- socket 阻塞,同步、I/O模型
1. 概念理解 在进行网络编程时,我们常常见到同步(Sync)/异步(Async),阻塞(Block)/非阻塞(Unblock)四种调用方式: 同步: 所谓同步,就是在发出一个功能调用时, ...
- LWIP在STM32实现
http://www.openedv.com/posts/list/25178.htm
- CentOS7 php7 安装 curl 扩展
直接从php源码包中,使用root权限安装. 找到原先安装PHP的源码包文件(如果已经删掉需要重新下载原来版本的源码包并解压) 我的php源码包在root家目录下. cd /php-7.1.4/ext ...
- Docker Toolbox常见错误解决方案
错误1 Error checking TLS connection: Error checking and/or regenerating the certs: There was an error ...
- PAT甲级目录
树(23) 备注 1004 Counting Leaves 1020 Tree Traversals 1043 Is It a Binary Search Tree 判断BST,BST的性质 ...
- python学习(二十) Python 中的比较:is 与 ==
Python 中的比较:is 与 == 在 Python 中会用到对象之间比较,可以用 ==,也可以用 is .但是它们的区别是什么呢? is 比较的是两个实例对象是不是完全相同,它们是不是同一个对象 ...
- socket链接循环
server------------------------#!/usr/bin/env python # encoding: utf-8 # Date: 2018/6/5 import socke ...
- 使用Dottrace跟踪.net代码执行时间
当程序遇到性能问题,如IIs请求反应缓慢,.net客户端程序执行缓慢,如何分析是哪里出了问题?dottrace可以帮助.net程序跟踪出代码里每个方法的执行时间,清晰的看出是哪里执行时间过长,然后再分 ...
- vertex shader(4)
Swizzling and Masking 如果你使用输入.常量.临时寄存器作为源寄存器,你可以彼此独立地swizzle .x,.y,.z,.w值.如果你使用输出.临时寄存器作为目标寄存器,你可以把. ...