After a long gap i'm gonna share one new feature in groovy ...its all about invoking the size method on each array element
Before going into Groovy...wanna to share some new pretty cool features of groovy over javaGroovy is known as Java scripting language and a lot of groovy users are taking advantage of its flexible nature. Groovy is better known as a new age advanced substitute of Java, or we can say it a better Java. Groovy takes advantage of static Java compiler and is purely a JVM based language, it generates bytecodes like Java and provides Java stability and trust in a better and flexible way.
Groovy is a JVM based dynamic language that runs on the Java Compiler. Groovy contains Java like syntax and design pattern most of the Java code is also valid in groovy but not all, rather groovy is much more dynamic and a new version of Java in a better and productive manner.
Although Java is a very good and widely used programming language but implementing some tasks like string manipulation and file handling is a a great pain in Java. Using Groovy one can implement and code difficult stuffs in a very dynamic and easy way. Groovy files have an extention of '.groovy' and unlike Java we do not need to put a semicolon after each programming statement. If you knows Java than its very easy to learn and implement groovy in your programming stuff.
Groovy is designed as much as familiar with Java and tried to make general purpose tasks easy.
for more info :- http://www.beingjavaguys.com/2013/02/what-is-groovy-java-vs-groovy.html
Wogay Let's dive into Groovy's pretty cool features:-
Use of spread-dot operator:-
def animals = ['ant', 'buffalo', 'canary', 'dog'] // Array declaration in groovy 'll be like this [] instead of {} in java
assert animals.size() == 4 // assert keyword-Enables you to test your assumptions about your program
assert animals*.size() == [3, 7, 6, 3] //size of each array element is given in the array
Moreover :- Semicolon is not needed in groovy :) :)
No comments:
Post a Comment