Reputation: 13395
Let's say I've got such interface
interface IFile {
void writeFile(String name, byte[] bytes)
byte[] readFile(String name)
}
How to do a coercion to that interface? Because so far that approach does not work and leads to compilation exception
def fileCoeImp = {
name, bytes -> new File(nane) << bytes,
name -> new File(name).getBytes()
} as IFile
Upvotes: 0
Views: 101
Reputation: 171094
You need to use a map:
def fileCoeImp = [
writeFile : { name, bytes -> new File(name) << bytes },
readFile : { name -> new File(name).getBytes() }
] as IFile
Upvotes: 4