return values from fork: fork_and_return by grosser — 15 July 2012 revert any side-effects like require or memory leaks and still get a result fork_and_return Comments gem install fork require ‘fork’ Fork.return { 1+1 } # => 2 I think it doesn’t get any simpler than that :D apeiros — 16 July 2012 oh, also if you don’t need the result immediately, the fork gem allows you to do: future = Fork.future { complex_calculation } # another complex calculation future.call # => result apeiros — 16 July 2012 Post a comment You can use basic HTML markup (e.g. <a>) or Markdown. Authenticate with GitHub As you are not logged in, you will bedirected via GitHub to signup or sign in
Comments
gem install fork
require ‘fork’ Fork.return { 1+1 } # => 2I think it doesn’t get any simpler than that :D
oh, also if you don’t need the result immediately, the fork gem allows you to do:
future = Fork.future { complex_calculation } # another complex calculation future.call # => result
Post a comment