Issue Details (XML | Word | Printable)

Key: GROOVY-21
Type: New Feature New Feature
Status: Closed Closed
Resolution: Won't Fix
Priority: Minor Minor
Assignee: Paul King
Reporter: james strachan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

.. as a new binary operator

Created: 03/Oct/03 03:31 AM   Updated: 10/Jun/07 04:14 AM
Component/s: lexer
Affects Version/s: None
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

Issue Links:
dependent
 


 Description  « Hide
Rather than having a special RangeExpression 0..5 we could just make .. an operator.

Then the .. operator on numbers could create a range and we can use this operator to do a 'traverse' on other objects. E.g. we can use .. to be like // in XPath.

e.g.

node = builder.foo() {
bar() { x("a") x("b") }
}
node..x

would yield [ x("a"), x("b") ]

We could also use .. to invoke methods on collections of objects too.

node..x..name() would yield ["a", "b"]



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
james strachan added a comment - 09/Jan/04 01:53 AM
Hmm, I'm not so sure about this now.

Jörg Gottschling added a comment - 15/Oct/05 06:26 AM
Seems as if this is implemented in the new ECMAScript4XML (E4X). I thing it would be nice to have this here.

John Wilson added a comment - 16/Oct/05 06:39 AM
GPath expressions use '.' for this functionality now. So node.x yields [x("a"), x("b")]

Paul King added a comment - 10/Jun/07 04:14 AM
Syntax not required as GPath handles this use case.