From: Kevin Smith Date: 2000-12-30T13:06:42+09:00 Subject: [ruby-talk:8327] Ruby implicit return values (was: Re: open3 woes) Dave Thomas wrote: >Holden Glova writes: > >> class RuntimeInterpreter >> >> def invoke(file) >> streams = Open3.popen3("ruby -w #{file}") >> streams.at(1).each() { |line| >> puts line >> } >> end >> end > >Q: what does 'invoke' return? I'm still developing my coding style for Ruby. I've been hit by problems similar to this several times, where either a) I've counted on a return but none was specified, so it was unpredictable, or b) I wanted the method to be considered "void" [C++ background speaking]. So I've considered having a policy that *ALL* methods will return something. For those that don't have a meaningful return value, they should have either "return nil" or "nil" as the last line. I would exclude setters from that rule, probably. Has anyone else been frustrated by this sometimes- handy "feature" of the language? Kevin