As you may know, there's a special variable _
of last expression in REPL's like irb
and pry
.
But can I get the result of last expression from Ruby platform?
Because of Ruby's dynamic nature and flexible compiler/virtual machine, maybe it's possible to get it from the Ruby's guts.
So I can avoid to write construction like this:
def some_method
result = begin
# some code
end
# do something with result
result
end
P.S. tap is not a solution for me