CLion 2024.1 Help

Extract lambda parameter

The Extract Lambda Parameter refactoring helps you extract an expression or statement into a new parameter with a lambda expression passed as a corresponding argument. For example, this could be a comparator passed to a sorting function.

The following demo illustrates the usage of the Extract Lambda Parameter refactoring, as well as Extract Function, Extract Parameter, and Live Templates:

Extract a lambda parameter

  1. Select a code fragment that you want to extract into a lambda parameter.

  2. Call Refactor | Lambda Parameter from the main menu or select Lambda Parameter from the Refactor This (Ctrl+Alt+Shift+T) popup.

    Extract Lambda Parameter option in Refactor This
  3. In the dialog that opens, specify the name, return type, and declaration placement for the new lambda parameter:

    The Extract Lambda Parameter dialog
  4. Review the changes in the Signature Preview field and click Extract when ready.

Last modified: 26 May 2024