"it"? "#"? ""?

Richard Warburton richard.warburton at gmail.com
Mon Nov 21 07:16:55 PST 2011


On 21/11/11 15:06, Matthew Adams wrote:
> Hi Remi,
>
> I don't understand what you're trying to say.  Are you saying that instead
> of "it", "#" or empty string (implicit closure param), "_" could be used as
> an implicit closure param?  If so, then Brian seems to have shot that down
> in his last email (no Scala wunderbars).  If not, please explain further.

I think what he means is that you can use the underscore character as a 
one character variable name.  So the example:

root.listFiles(_ -> _.lastModified()<= before);

means the same thing as say:

root.listFiles(x -> x.lastModified()<= before);

So if you were to want wunderbars then you'be able to write something like:

(_.doSomething())

but if you don't have them you can still write:

(_ -> _.doSomething())

ie the best you're doing is saving the user typing 5 characters 
including whitespace, or 3 excluding whitespace.  The decision makes a 
lot more sense to me after this argument has been explained.

regards,

   Richard


More information about the lambda-dev mailing list