Skip to content

Instantly share code, notes, and snippets.

@mynyml
Created February 10, 2010 13:26
Show Gist options
  • Save mynyml/300302 to your computer and use it in GitHub Desktop.
Save mynyml/300302 to your computer and use it in GitHub Desktop.
~/dev/tmp| irb
>> a = File.open('foo')
=> #<File:foo>
>> File.open('foo', 'w') {|f| f << 'foo' }
=> #<File:foo (closed)>
>> a.rewind; a.read
=> "foo"
>> File.open('foo', 'w') {|f| f << 'bar' }
=> #<File:foo (closed)>
>> a.rewind; a.read
=> "bar"
>> # manually edit file 'foo' to contain 'hello' (in editor)
?> a.rewind; a.read
=> "bar"
>> File.open('foo', 'w') {|f| f << 'baz' }
=> #<File:foo (closed)>
>> a.rewind; a.read
=> "bar"
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment