The Artima Developer Community
Sponsored Link

Java Buzz Forum
New Groovy "use" method added by Sam

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
New Groovy "use" method added by Sam Posted: Apr 27, 2004 9:23 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: New Groovy "use" method added by Sam
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
Sam Pullara has added a cool new feature to Groovy. There is a new method use which allows you to introduce methods to existing class. At the moment this works just for the duration of closure, but in the future you will be able to use it elsewhere. This is pretty cool. I also would love to see: Feature plugin/out: It would be great to use this mechanism to allow "features" of the language to be plugged in and out. It could enable backwards compatibility in the future, allowing changes to the language as experience shows us what to do (one worry wrt standardizing before a real impl is out there!) Flush out AOP-isms: Mixin's are great, but I would love to see a PointCut language, and rich support From Sam's Email: excerpt from src/test/groovy/xml/dom/DOMTest.groovy: xml = new StringReader("<html><head><title class='mytitle'>Test</title></head><body><p class='mystyle'>This is a test.</p></body></html>"); doc = DOMBuilder.parse(xml); html = doc.documentElement; use (groovy.xml.dom.DOMCategory) { assert html.head.title.textContent == "Test"; assert html.body.p.textContent == "This is a test."; assert html.find { it.tagName == "body" }.tagName == "body"; assert html.getElementsByTagName("*").findAll { if (it["@class"] != "") { return it } }.size() == 2; }

Read: New Groovy "use" method added by Sam

Topic: IQ is a Relatively Meaningless Number Consumed by Egotistical Narcissists Previous Topic   Next Topic Topic: 5 more papers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use