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 trialBrian Weeks
4,967 PointsIs there a difference between yield and &block with block.call
Is there any functional difference between yield and using &block with block.call? When might I use one over the other?
1 Answer
Nathan Williams
Python Web Development Techdegree Student 6,851 Pointsyield
is implicit, meaning it executes a block (if passed) immediately. &block
is explicit, so you actually get a variable that refers to the block, and you could potentially pass the block into another method as an argument :)
it's also a little clearer to users looking at the method signature that the method expects a block, so if it's required, you'd probably want to make it explicit.