FAQ: Blocks, Procs, and Lambdas - Been Around the Block a Few Times

This community-built FAQ covers the “Been Around the Block a Few Times” exercise from the lesson “Blocks, Procs, and Lambdas”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Ruby

FAQs on the exercise Been Around the Block a Few Times

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

A request for a bit more clarification: how does method syntax impact the bigger picture? For example, are both of these approaches (.select vs lambda) valid?

ints = odds_n_ends.select { |x| x.is_a? Integer }

int_search = lambda { |x| x.is_a? Integer }

ints_1 = odds_n_ends.select(&int_search)

If so, is one preferable to the other?

Although I got it correct, why does this following error appear?

(test):14: warning: found = in conditional, should be ==
2 Likes

I got the same error even though my code passed/I was able to proceed and I saw zero instances of the error actually being applicable to my code; I think it’s just a bug.

1 Like

I think it’s totally context-dependent; in this case, it truly doesn’t matter at all given the context. Ruby, it seems, really stresses the whole “multiple ways to do the same thing”, with each of those ways possibly being more or less applicable given the context; here, it seems like the context doesn’t necessitate one vs. the other, so it’s purely arbitrary to use a lambda or a proc.

This is coming from a total newbie, so take that with a grain of salt or three - just my two cents.

my answer was basically the same but without the space in the block, as below:

ints = odds_n_ends.select { |x| x.is_a?Integer }

This did not produce the error, but did so with the space. I don’t know why though!

1 Like