File.open(local_filename, 'w') {|f| f.write(doc) }
Draft This article hasn't been published, so readers can't see it. In moderation This article is waiting for review, so readers can't see it yet. Deleted This article has been deleted, so readers can't see it. Ruby: Open A File, Write To It, And Close It In One Line By About Snippets Manager Snippets Manager · Jan. 29, 08 · Code Snippet Like Likes 0 Comment Save Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab) 38.8K Views File.open(local_filename, 'w') {|f| f.write(doc) } Opinions expressed by DZone contributors are their own.