Groovy 学习笔记 (五)

(1..10).each{ log += it } 等价于 (1..10).each({ log += it }) Closure声明方式之一是: reference.& (其中receiver是对象) def adder = { x, y -> return x+y } 等价于 adder(4, 3) 或 adder.call(2, 6) 文件读写更加简单: def file = new File(‘myFileName.txt’) for (line in file) println line 方法的最后一个语句得到的值作为返回值,所以return语句是可选的 异常不强制要求捕获 for (it in aaa) 中,变量 aaa 可以是字符串,可以是对象,等等 def file = new [...]

By javafuns on September 9, 2009 at 21:50 · Views: 391 · Permalink · RSS · Leave a comment
Categorized in: Scripts · Tagged with: , ,

Groovy 学习笔记 (四)

Groovy 支持操作符重载, 每个操作符对应一个方法签名, 如‘+’对应的是’plus’. Groovy 支持多种字符串表示, 单引号, 双引号(支持GString), 3个单引号(支持多行), 3个双引号(支持多行, 支持GString). 在 Groovy 中, 方法的括号是可选的, 如果一行只有一个语句, 那么语句后的分号也可省略不写. Groovy range, 可用于: 数字, 日期, 字符串. 只要数据类型实现了 next(++), previous(–), 和 java.lang.Comparable 接口, 就可以使用 range . Groovy list 默认使用 ArrayList, 欲使用 LinkedList 等其它类型 List, 需要明确声明. List 可以使用负值作为index值进行访问, 例如 list[-1]返回的就是list的最后一个值, list[-2]则返回倒数第二个值. 也可以指定倒序的 range, 如list[4..0]. 需注意: list[0..<-2] 等价于 list[0..-1] 而非 list[0..-3]. [...]

By javafuns on August 25, 2009 at 22:22 · Views: 432 · Permalink · RSS · Leave a comment
Categorized in: Scripts · Tagged with: , ,

Groovy 学习笔记 (三)

1. == 是判断是否 equals, 而判断是否是同一对象则用 is 2. list 和 map 的一些方法: def x  = 1..10 assert x.contains(5) assert x.contains(15) == false assert x.size()    == 10 assert x.from      == 1 assert x.to        == 10 assert x.reverse() == 10..1 3. 以下对象都有 size() 方法 Array, String, StringBuffer, Collection, Map, File 4. 数据类型:12 – Integer, 100L – Long, 1.23F [...]

By javafuns on August 5, 2009 at 22:21 · Views: 401 · Permalink · RSS · Leave a comment
Categorized in: Scripts · Tagged with: , ,

Groovy 学习笔记 (二)

5. 方法调用: 方法调用时, 括号是可选的. 例如: print ‘hello, world’ 6. 方法返回值: 默认最后一句就是方法的返回值, 也就是说, 最后一句的return语句是可有可无的. 当然, 如果在方法中间需要return值, 还是要写 return 语句才行. 7. 闭包(closure): 闭包可以访问与闭包定义在同一scope的变量. 例如: def name = “” //initialize variable def printName = { println “The string in the name variable is ” + name } //define method name = “Youssef” //set string Youssef in variable name [...]

By javafuns on May 4, 2009 at 17:47 · Views: 3,426 · Permalink · RSS · Leave a comment
Categorized in: Scripts · Tagged with: , , ,

Java Scripting Programmer’s Guide

Java 6 引入了 script 功能, 使得很多 script language 可以运行于 Java VM 中. 这会给我们的很多应用带来很有趣又很有用的特性, 比如将一些(需动态改变的)业务逻辑交给这些 script language 来处理. 本文翻译自 <Java Scripting Programmer’s Guide>. ——————————————————— Table Of  Content Who is the Java Scripting API For? Scripting Package Examples “Hello, World” Evaluating a Script File Script Variables Invoking Script Functions and Methods Implementing Java Interfaces by Scripts Multiple [...]

By javafuns on February 23, 2009 at 09:57 · Views: 1,728 · Permalink · RSS · Leave a comment
Categorized in: Java · Tagged with: ,

Add a new plugin for twitter

“Twitter is a free social networking and micro-blogging service that allows its users to send and read other users’ updates (otherwise known as tweets), which are text-based posts of up to 140 characters in length.”

— Wikipedia.org

By javafuns on January 10, 2009 at 08:21 · Views: 1,537 · Permalink · RSS · Leave a comment
Categorized in: My Life, Scripts · Tagged with: , ,

制作了一个wordpress的收藏插件

花费了一下午加半个晚上时间,制作了这个供收藏用的插件。 对php不熟悉,什么都要查资料,太费时费力了。 不过,通过这个小插件,基本搞懂了如何开发wordpress插件了。

By javafuns on May 25, 2008 at 21:44 · Views: 1,003 · Permalink · RSS · Leave a comment
Categorized in: Scripts · Tagged with: ,

让你的wordpress能够发送邮件

wordpress不能发邮件是很郁闷的,因为有些功能是需要邮件通知的,譬如说有新评论啦,等等。 《让 WordPress 通过 SMTP 发送邮件》介绍了可以让你的wordpress发送邮件的3个插件,这3个插件不是使用操作系统的邮件服务器而是实实在在的php函数: Configure SMTP WP Mail SMTP Swift SMTP Plugin

By javafuns on April 27, 2008 at 21:45 · Views: 1,793 · Permalink · RSS · Leave a comment
Categorized in: Scripts · Tagged with: ,
  • Highest Rated

  • My PicasaPhotos

    IMG_0570.JPG

    IMG_0528.JPG

    IMG_0657.JPG

  • RSS My del.icio.us

  • My RSS