implementing Interfaces with closures in Groovy - what method was called? -
To apply an interface with a single closing, there is a phrase in groovy which are used to handle logic Should be closed for It works fine but how does it decide which method was called in the interface?
interface x {void f (); Zero G (Int N); Zero (string s, int n); } X = {Object [] Args - & gt; Println "x $" is available as a xx () , but the method is named after that name - apparently - no. Am I missing something?
I think that Michael Borgwaart is essentially right. You provide an method implementation implementation that provides curly bracket syntax through all interface definitions :
interface x { Void f (); Zero G (Int N); Zero (string s, int n); } X = {Object [] Args - & gt; XL () Exag (5) xh ("a string", 2) As if you want to close one with a method implementation method, this alternative syntax Use:
Interface X {void f (); Zero G (Int N); Zero (string s, int n); } X = [f: {println is called "f"}}, g: {int i-> Println "is called with the ultimate $ {i}"}, h: {object [] args - & gt; For more information as an X X () XG (5) Xh ("A string", 2) see the following:
/ P>
Comments
Post a Comment