Groovy Operators

Control Statements

Groovy File Handling

Groovy Error & Exceptions

Groovy Multithreading

Groovy Synchronization

Groovy - Range getFrom() method



getFrom() method returns the lower value of this Range.

Syntax

Comparable getFrom()

Parameters

NA

Return Value

Returns the lower value of the range.

Example - Getting lower value of range of numbers

Following is an example of the usage of getFrom() method.

Example.groovy

class Example { 
   static void main(String[] args) { 
      // range of numbers
      def array = 1..10;		
      println(array.getFrom());     
   } 
}

Output

When we run the above program, we will get the following result −

1

Example - Getting lower value of range of characters

Following is an example of the usage of getFrom() method.

Example.groovy

class Example { 
   static void main(String[] args) { 
      // range of characters
      def array = 'a'..'z'; 
      println(array.getFrom());
   } 
}

Output

When we run the above program, we will get the following result −

a

Example - Getting lower value of range of special characters

Following is an example of the usage of getFrom() method.

Example.groovy

class Example { 
   static void main(String[] args) { 
      // range of special characters
      def array = '&'..'!'; 
      println(array.getFrom());     
   } 
}

Output

When we run the above program, we will get the following result −

!
groovy_ranges.htm
Advertisements