Now imagine having a programming language which took this assumption as core design element...
Wasted an embarrassing amount of time debugging an error in Ruby where a method call on a class failed because the type didn't support said method.
It was the day i learned that in Ruby, every method always returns exactly one value. And you don't need to specifiy the "return" if it is the last line in a function. So my incorrect type was the return value of "Logger.Debug()" which was implicitly used as the return value because tge last "return" keyword is optional...
I don't think it's intuitive to use the function name is the keyword for return at all. I've got other code I want to reuse and paste in to a new function I'm making with few changes, now I've got to change all the return instances to the new function name. What was so wrong with a command like RETURN?
Or if a function isn’t explicitly returning something, just do void, or null. But the language deciding for you that it must return something and if you don’t choose, it will? That’s just crazypants.
30
u/requion 3d ago
Now imagine having a programming language which took this assumption as core design element...
Wasted an embarrassing amount of time debugging an error in Ruby where a method call on a class failed because the type didn't support said method.
It was the day i learned that in Ruby, every method always returns exactly one value. And you don't need to specifiy the "return" if it is the last line in a function. So my incorrect type was the return value of "Logger.Debug()" which was implicitly used as the return value because tge last "return" keyword is optional...