Comments are part of the code we write that will be ignore by the groovy console
Comments are used to explain the code we are making so that others or even ourselves can understand it later.
There are 2 types of comments:
Single line comments are done using double slash //
- def x =1
- def z =2
- // This part will be ignored by the console
- def y =x + Z
Multi-line as the name says, can be written on multiple lines and are signaled by encapsulating the lines in between /* and */
- def a = 3
- This is a
- comment on
- def c = a + 7
This words are reserved words in groovy
That means that they can not be used as variable names or for other purpose except the one that they have been assigned to.
Here is a table of this keywords
This means this words can not be used for example as variable names:
def new = 11
Doing this will give an error when trying to save your script.
but if you do def random = new Random()
This will not give you an error, as new keywords is used in the way it was designed to be used in groovy.