3 ms·
That's a first world problem of ruby devs I think. When you're used to it, you never forget to write return statements.
by Seldaek 15y ago
That's a first world problem of ruby devs I think. When you're used to it, you never forget to write return statements.
- Confusion 15y agoRuby is far from the only language that is commonly used without explicit return statements (and it at least has them). It's just currently the most popular one.
- rubergly 15y agoAgreed. I hardly think that people who haven't used languages like Ruby or Coffeescript (with implicitly returning the last expression) ever forget return statements in a way where everything would be okay if they just added a "return" keyword. When I use Ruby and Coffeescript, I consciously have to think "no, I _shouldn't_ write return this time"; I find it hard to believe that, without using a language like this, anyone would just write an expression and expect it to be returned. I could see an argument that if you're returning the application of a function, but it has always seemed extremely natural to me that I think about what I'm returning when I write a function; I actually always have a little bit of trouble adjusting to writing Ruby-style return-less code.
- rawsyntax 15y agoit depends on how you think of functions... If you think of everything as an expression, of course it has some kind of value. That being said I prefer not to have to write "return" but work plenty with languages outside of ruby and have no issues writing return when necessary.
- technomancy 15y ago> it depends on how you think of functions... If you think of everything as an expression, of course it has some kind of value. Sure, and functions by definition return a value. I know programming isn't math, but the notion of a "void function" is somewhat of an oxymoron.
- technomancy 15y agoRuby, Lisp, Smalltalk, Python, Forth, Perl... Nearly anything that's not a descendant of C or Basic lets you write in terms of expressions.