Issue Details (XML | Word | Printable)

Key: GROOVY-2036
Type: New Feature New Feature
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Dave Syer
Votes: 1
Watchers: 1
Operations

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

There is no equivalent of Ruby's respond_to - you have to catch MissingMethodException

Created: 10/Aug/07 05:26 AM   Updated: 16/Oct/07 09:01 AM
Component/s: None
Affects Version/s: 1.1-beta-2
Fix Version/s: 1.1-rc-2

Time Tracking:
Not Specified


 Description  « Hide
There is no equivalent of Ruby's respond_to - you have to catch MissingMethodException. E.g.

try {
value = value.toGroovy()
} catch(MissingMethodException) {}
value

instead of

if (value.respondTo("toGroovy")) {
value = value.toGroovy()
}
value



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Luke Daley added a comment - 12/Aug/07 02:34 AM
'respondsTo' reads more naturally. I would prefer the method to be called 'respondsTo' over 'respondTo'.

Paul King added a comment - 16/Oct/07 09:01 AM
Duplicate of GROOVY-2109.