Groovy Beginner Tutorial 16 | Closures

  Рет қаралды 26,308

Automation Step by Step

Automation Step by Step

Күн бұрын

Take the Groovy Quiz - automationstep...
Closures
What are closures
How to use closures
Why do we need closures
a block of code that can
- take parameters
- refer variables
- return values
- can be passed as parameter in a method
References
/ practical-uses-for-clo...
www.quora.com/...
SUBSCRIBE & Click Bell to Join Automation Step-by-Step family
JOIN me on this educational journey as a member and get exclusive perks - Click the JOIN button
/ @raghavpal
----------- UI TESTING -----------
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework with RIDE- bit.ly/2Px6Ue9
Robot Framework with Eclipse - bit.ly/2N8DZxb
----------- API TESTING -----------
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
General - bit.ly/2PYdwmV
Katalon Studio API Testing - bit.ly/2BwuCTN
----------- MOBILE TESTING -----------
Mobile Playlist - bit.ly/2PxpeUv
----------- CI | CD | DEVOPS -----------
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
----------- VERSION CONTROL SYSTEM -----------
Git & GitHub - bit.ly/2Q1pagY
----------- PERFORMANCE TESTING -----------
JMeter Beginner - bit.ly/2oBbtIU
JMeter Intermediate - bit.ly/2oziNVB
JMeter Advanced - bit.ly/2Q22Y6a
JMeter Tips & Tricks - bit.ly/2NOfWD2
Performance Testing - bit.ly/2wEXbLS
----------- JAVA -----------
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
----------- MAVEN -----------
Maven - bit.ly/2NJdDRS
----------- OTHERS -----------
Redis- bit.ly/2N9jyCG
Misc - bit.ly/2Q2q5xQ
Tools & Tips - bit.ly/2oBfwoR
QnA Friday- bit.ly/2NgwGpw
Sunday Special - bit.ly/2wB23BO
Ask Raghav - bit.ly/2CoJGWf
Interviews - bit.ly/2NIPPxk
All Playlists - bit.ly/2LSiezA
Keep Learning,
Raghav
Website - automationstep...
LifeCharger -
Udemy Courses - www.udemy.com/...
Facebook - / automationstepbystep
Twitter - / automationsbs
KZbin - / automationstepbystep
You can support my mission for education by sharing this knowledge and helping as many people as you can.

Пікірлер: 28
@ksuhdilla
@ksuhdilla 2 жыл бұрын
great video - thank you so much A lot of thoughts go into these videos and I even like the quizzes you have made
@RaghavPal
@RaghavPal 2 жыл бұрын
Most welcome
@tayal11991
@tayal11991 5 жыл бұрын
Very informative...👍
@RaghavPal
@RaghavPal 5 жыл бұрын
Thanks for watching Himanshu
@victorm9487
@victorm9487 3 жыл бұрын
Thank u great explanation !
@RaghavPal
@RaghavPal 3 жыл бұрын
Most welcome Victor
@CodeWithSeenu
@CodeWithSeenu Жыл бұрын
This is very informative. So, closures in groovy is like static methods in java?
@RaghavPal
@RaghavPal Жыл бұрын
Srinivas No, closures in Groovy are not like static methods in Java. A closure in Groovy is an anonymous function that can be passed around as an object. It can access the variables that were in scope when it was created. A static method in Java is a method that is associated with a class, not with an object. It can only access the variables that are declared as static in the class. Here is an example of a closure in Groovy: ``` def myClosure = { println "Hello, world!" } ``` This closure takes no arguments and returns nothing. It prints the string "Hello, world!" to the console. Here is an example of a static method in Java: ``` public static void myStaticMethod() { System.out.println("Hello, world!"); } ``` This method takes no arguments and returns nothing. It prints the string "Hello, world!" to the console. As you can see, the closure and the static method are both anonymous functions. However, the closure can access the variables that were in scope when it was created, while the static method cannot. I hope this helps
@BabuD4m
@BabuD4m 5 жыл бұрын
you can call variable inside the function or method. But the variable should be as a global variable. ex: a=100 //global variable def b=200 //local variable because of def def m1() { println(a) // will be 100 here //println(b) // will be error here since calling local variable } m1() this will apply every where in groovy .
@RaghavPal
@RaghavPal 5 жыл бұрын
Thanks for adding this
@ramvijay1648
@ramvijay1648 4 жыл бұрын
Really Helpful, Thanks for the session given on Closures. Can you please make a video on Operator like > in groovy
@RaghavPal
@RaghavPal 4 жыл бұрын
Noted Ram
@rainerhaseneder2480
@rainerhaseneder2480 4 жыл бұрын
Thanks for the video. I haven't got yet though why we need it though. :-) The only notion I got is that closures allow you to nest functions and bring some default features/methods, because anything is an object in Groovy and brings along those default features/methods. My starting point is a code example as Jenkinsfile (a script written in Groovy) where there is one closure inside a function and this closure executes one very long make command in a shell. This is all and the closure is called exactly one time. I see also a comment that this is done to avoid code duplication. Maybe you have another idea ? :-)
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Rainer, I know the concept of closure is a little tricky. I will plan to have a separate session on understanding closures
@sadabhasan8814
@sadabhasan8814 4 жыл бұрын
very good ...Very need full
@RaghavPal
@RaghavPal 4 жыл бұрын
Thanks for watching Sadab
@udaykumark27
@udaykumark27 4 жыл бұрын
Thanks for your Video it's really useful...
@RaghavPal
@RaghavPal 4 жыл бұрын
Glad to hear that Uday
@saqibahmed3382
@saqibahmed3382 3 жыл бұрын
Hello thank u for making groovy script making us understand easily, where is the notes of all these concepts??
@RaghavPal
@RaghavPal 3 жыл бұрын
notes available in the description below the video
@digitalbunny3284
@digitalbunny3284 4 жыл бұрын
I"m not quite understands this part myList.find {}? I'm not sure what this is.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi, So it is an inbuilt function and uses a closure. I will suggest to check more examples online
@vinaysiri6786
@vinaysiri6786 5 жыл бұрын
made it simple
@RaghavPal
@RaghavPal 5 жыл бұрын
Happy to know that Vinay
@learntolearn1063
@learntolearn1063 2 жыл бұрын
in the 7:45 you used the each method to print the list using the closures but the example is not true because you did not use the closures to print the items rather than you used the print method . The right example should be like that def list = ["apples","Orange","Grapes"] list.each { element -> print("the element is : ${element} ") }
@RaghavPal
@RaghavPal 2 жыл бұрын
Ok, will check this
@dipi411
@dipi411 Жыл бұрын
It's very confusing
@RaghavPal
@RaghavPal Жыл бұрын
Hi Bhabani, let me know what exactly is the issue
Groovy Beginner Tutorial 17 | Lists
17:55
Automation Step by Step
Рет қаралды 20 М.
Java 8 Lambda Basics 19 - Closures in Lambda Expressions
8:30
Java Brains
Рет қаралды 147 М.
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 13 МЛН
SCHOOLBOY. Мама флексит 🫣👩🏻
00:41
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 7 МЛН
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 67 МЛН
SHAPALAQ 6 серия / 3 часть #aminkavitaminka #aminak #aminokka #расулшоу
00:59
Аминка Витаминка
Рет қаралды 1,1 МЛН
Groovy Beginner Tutorial 11 | Conditional Statements | if else switch case
12:25
Automation Step by Step
Рет қаралды 32 М.
10 Things You Can Do With Groovy Closures!
26:08
Szymon Stepniak
Рет қаралды 19 М.
Groovy Beginner Tutorial 14 | Strings
22:45
Automation Step by Step
Рет қаралды 22 М.
Postman Beginner's Course - API Testing
2:09:38
freeCodeCamp.org
Рет қаралды 2,4 МЛН
Learn Closures In 7 Minutes
6:56
Web Dev Simplified
Рет қаралды 330 М.
Groovy Beginner Tutorial 21 |  How to read files in groovy
22:48
Automation Step by Step
Рет қаралды 28 М.
Groovy DSL scripts in 20 minutes for beginners
23:02
Szymon Stepniak
Рет қаралды 37 М.
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 13 МЛН