Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy & IntelliJ: how to extract variable with explicit type declaration?

How to extract variable (cmd+alt+v) in Groovy in IntelliJ to get this:

Car car = new Car()

instead of this?

def car = new Car()
like image 687
Dariusz Mydlarz Avatar asked Jan 13 '16 13:01

Dariusz Mydlarz


People also ask

What is Groovy?

The def keyword is used to define an untyped variable or a function in Groovy, as it is an optionally-typed language.

What Groovy used for?

Groovy is a dynamic object-oriented programming language for the Java virtual machine (JVM) that can be used anywhere Java is used. The language can be used to combine Java modules, extend existing Java applications and write new applications.

Is Groovy still used?

The initiatives like GR8DI help underrepresented minorities to begin their journey in Groovy ecosystem by education and collaboration. And last but not least - Groovy is still one of the most downloaded libraries in the Java ecosystem.

Why is Groovy so popular?

Groovy is a Java enhancer because it provides greater flexibility and even introduces special features to applications (those that have already been developed can be improved or they can be made from scratch). Groovy is a Java-like syntax, but with the ease of more moldable languages like Python and Ruby.


1 Answers

Use Shift + Tab on def and choose type. Next time Intellij will use specified type.

like image 104
mdabrowski Avatar answered Oct 26 '22 06:10

mdabrowski