From: bradley.schaefer@... Date: 2020-07-02T16:45:42+00:00 Subject: [ruby-core:99034] [Ruby master Feature#17004] Provide a way for methods to omit their return value Issue #17004 has been updated by soulcutter (Bradley Schaefer). jeremyevans0 (Jeremy Evans) wrote in #note-16: > soulcutter (Bradley Schaefer) wrote in #note-15: > > Also, how would you test this behavior? > > ```ruby > # return value not discarded case > some_method.must_equal :expected_return_value > check_for.must_equal :some_side_effect > > # return value discarded case > some_method > check_for.must_equal :some_side_effect > ``` That's fair. There's still a warning flag in my head that there's some subtle case where it is trickier to test, but I might be struggling to wrap my head around all the implications. Given that I can't come up with that example at the moment, I retract that problem-statement. ---------------------------------------- Feature #17004: Provide a way for methods to omit their return value https://bugs.ruby-lang.org/issues/17004#change-86409 * Author: shyouhei (Shyouhei Urabe) * Status: Open * Priority: Normal ---------------------------------------- In ruby, it often is the case for a method's return value to not be used by its caller. Even when a method returns something meaningful, its caller is free to ignore it. Why not provide a way for a method to know if its return value is needed or not? That adds a room for methods to be optimized, by for instance skipping creation of complex return values. The following pull request implements `RubyVM.return_value_is_used?` method, which does that: https://github.com/ruby/ruby/pull/3271 -- https://bugs.ruby-lang.org/ Unsubscribe: