Generate anonymous function feature

Posted on by Alexander Podkhalyuzin

In Scala, you can use anonymous functions. Now you can generate them automatically in case if it’s method call argument.

Lets, for example you have the following code:

Then use smart completion (Ctrl + Shift + Space) to see an appropriate variant:

After the completion you will get:

This feature works like Live Template, so you will be able to replace variable names and abstract types (in the next example Int is chosen automatically for ‘foldLeft’ type parameter, but you can replace it, if you want).

Also you can use brace syntax for method call (then partial anonymous function will be generated):

After completion you will get:

Comments below can no longer be edited.

3 Responses to Generate anonymous function feature

  1. Jem says:

    May 24, 2011

    Thank you so much for this! The plugin just gets better and better.

    I guess this feature is not available yet? When will the plugin update be pushed? Thanks again.

  2. Taras Tielkes says:

    May 25, 2011

    Jem, if you’re feeling adventurous, you can get nightly builds here:

  3. Alain O'Dea says:

    May 31, 2011

    This feature will be hugely helpful. It’s like the iterator and foreach live templates for Java but better since it has contextual completiom and type selection.

    Keep up the good work guys!