Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
1.0
-
None
Description
Currently if you want to do something with a character stream i.e. Reader its common to provide multiple methods.
doSomething(Reader)
doSoemthing(File)
doSomething(URL)
doSomething(String)
And the File, URL, String methods will do extra operations to create a reader before calling doSomething(Reader).
The other option is to only have the reader method and make the caller perform those operations.
It would be nice if groovy could mash an object into another type to fit the parameters. i.e. If you called a method taking a Reader and you passed a File, it would create a new FileReader for you.
Maybe it looks for a method called toReader on the parameter?
Obviously this can create problems, like oversimplifying character encoding issues with readers etc. And may lead to bad APIs when called from Java. But its a timesaving feature. Any thoughts.