Generate anonymous function feature

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:

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

3 Responses to Generate anonymous function feature

  1. Jem says:

    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:

    Jem, if you’re feeling adventurous, you can get nightly builds here:
    http://confluence.jetbrains.net/display/SCA/Scala+Plugin+Nightly+Builds+for+IDEA+X

  3. Alain O'Dea says:

    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!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>