can i create an method inside the main method and also call it inside the main method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can i create an method inside the main method and also call it inside the main method

14th May 2019, 8:52 AM
Trevor Chihombori
Trevor Chihombori - avatar
4 Answers
+ 3
You can do it using lambda expressions/functions. For example in C++ like: auto fn=[]{ std::cout<<"You called";}; fn();
14th May 2019, 9:05 AM
Mensch
Mensch - avatar
+ 1
An expression is not a method. And there is no need to do this!
14th May 2019, 9:18 AM
Daniel Adam
Daniel Adam - avatar
0
thanks man.. appreciate the help.. i was stuck
14th May 2019, 9:06 AM
Trevor Chihombori
Trevor Chihombori - avatar