Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Emmanuel Obi](https://secure.gravatar.com/avatar/12ce474dcb3c4d38ea5d565299dc5821?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Emmanuel Obi
14,912 PointsWhy does output from "return_from_labmda" method return the last line of the method?
As expected, the "return_from_proc" method returned the proc contents after called with "variable.call". I expected a similar result with "return_from_lambda", but it returned the last line of the method.
It seems as though the lambda version of the method "returns from the method" rather than "from the lambda" as said in the video. Thoughts?
1 Answer
Luke Buśk
21,598 PointsProc instantly returns from the block and breaks any further operation inside method, Lambda on the other hand returns from block and goes back to the caller (so returns back to the method). Method's always return the last line of code.
Emmanuel Obi
14,912 PointsEmmanuel Obi
14,912 PointsSimple as that, huh? Thanks for the clarification!
I guess lambdas would be good as 'remote code' that is incorporated in a number of different methods. Procs, on the other hand, seem like they would be interesting as a method of flow control...
Luke Buśk
21,598 PointsLuke Buśk
21,598 PointsIm not experienced enough yet but i believe Proc's are too risky to use and lambda is usually a better choice.