3 ms·
The break/next/return behavior is not sensible at all. Anybody that comes to ruby with knowledge of other languages with first-class functions will be confused
by seliopou 14y ago
The break/next/return behavior is not sensible at all. Anybody that comes to ruby with knowledge of other languages with first-class functions will be confused by it, in particular return.
Having said that, once you learn the difference it's not that big a deal.
- masklinn 14y ago> The break/next/return behavior is not sensible at all. They are. Especially return. > Anybody that comes to ruby with knowledge of other languages with first-class functions will be confused by it, in particular return. Not necessarily, and especially not if they happen to understand what "block" means, and why Ruby uses "block" not "lambdas" for its core. Or if they have the slightest inkling of knowledge of Smalltalk and/or Self. And either way, unless they've already fossilized the difference is easy to learn (and solves important issues in imperative languages)
- seliopou 14y agoA return statement in a block is more or less a call to an escape continuation. So is break. Most programmers don't know what an escape continuation is, though once explained can use them. Even if they did, those escape continuations are captured implicitly. There's no reason to believe that people are just going to divine their meaning. And if they're new to Ruby, they're not going to understand what a block is, pretty much by definition. It's a feature that's pretty unique to Ruby.
- masklinn 14y ago> A return statement in a block is more or less a call to an escape continuation. So? > Most programmers don't know what an escape continuation is Not that they have any reason to care. > There's no reason to believe that people are just going to divine their meaning. I don't think I ever said that. > And if they're new to Ruby, they're not going to understand what a block is, pretty much by definition. It's a feature that's pretty unique to Ruby. It's not for any known value of "unique". Blocks are present in most C-like languages, and first-class blocks were introduced by Smalltalk.