Groovy - Create and access the global variables Code Example

Here is the solution for "Create and access the global variables" in Groovy.

Groovy code for Create and access the global variables

import groovy.transform.Field

one = 'one_value'
@Field String two = 'two_value'
def three = 'three'

void printVars() {
    println one
    println two
    println three // This won't work, because not in script scope.
}
Code by IncludeHelp, on March 13, 2023 22:39

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.