DEV Community


Discussion on: Intro To Ruby Procs and Lambdas(and the difference)

darkwiiplayer profile image
DarkWiiPlayer • Edited

At first I wasn't sure if this was a troll post, but I assume it's not.

Setting aside that proc {} is syntactic sugar for {} and definitely valid ruby code, I took your statement

Lambdas, which mind you are still nameless functions, aren't evaluated until they're called. But Procs are a class type so they're evaluated immediately.

to mean that Procs, unlike Lambdas, are evaluated as soon as they are defined, which they are not. They both get evaluated when they receive a :call signal; there's no difference whatsoever between either of them. If that wasn't what you meant, please clarify. You're not being very specific in your vocabulary, so it is difficult to know exactly what you mean and I might just be misunderstanding you.

EDIT: Some extra advise: don't tell people to "learn X". Even if you actually know what you're talking about, it makes you come across as a dick, and, if on top of it you're wrong, it makes you look even worse. Next time, either just open irb and check for yourself if something is correct, or be more open in your statement, like "I think you're wrong". Don't just assume people on the internet don't know what they're doing or it might backfire really hard.

Thread Thread
seanolad profile image
Sean Author

Okay, at this point I'm kind of out of fuel to argue so I'll set aside the argument, I didn't know that proc was synthetic sugar for since that turns out to be true I'll read over my post and thoroughly check if what you're saying checks out. Hope I wasn't too toxic in any of my responses I get defensive sometimes. Nevertheless you're a dev, so your opinion should be heard and all warnings heeded. Again, sorry, I may have lost it.