Skip to content

Instantly share code, notes, and snippets.

@yancya
Created September 29, 2017 06:56
Show Gist options
  • Save yancya/89235d578a1d19e8ca7a1f466ca18341 to your computer and use it in GitHub Desktop.
Save yancya/89235d578a1d19e8ca7a1f466ca18341 to your computer and use it in GitHub Desktop.
with_resources のサンプル
require 'with_resources/toplevel'
using WithResources::TopLevel
resources = -> () {
hello = StringIO.new('Hello')
world = StringIO.new('World')
}
with(resources) do |hello, world|
puts "#{hello.gets}, #{world.gets}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment