How are procs similar to methods? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How are procs similar to methods?

4th Mar 2017, 6:30 AM
Emmanuel Nuotah
2 Answers
+ 4
If I had to draw any lines, I'd say procs are basically delegates. A neat little way to assign methods to a variable, making it easy to pass to another method. I suggest using procs only for simple actions that require no parameters and return no value, and using lambdas instead in those cases, as they are able to return without issue, just like a normal method, and warn you if you're not giving it the expected parameters.
8th Mar 2017, 5:12 AM
Dao
Dao - avatar
+ 3
Procs are objects which return themselves unlike blocks which are a part of the methods' call syntax.Procs also do not mean anything on thier own and can only appear in argumets.
3rd Oct 2019, 5:57 PM
Kevin Omondi
Kevin Omondi - avatar