LWN.net Logo

Ruby

Ruby

Posted Mar 28, 2008 1:15 UTC (Fri) by Tuxie (subscriber, #47191)
In reply to: Python by pr1268
Parent article: Striking gold in binutils

sorry, I had to :-)

x = File.read("foo.txt").to_i rescue deadParrot


(Log in to post comments)

Ruby

Posted Mar 28, 2008 16:08 UTC (Fri) by alkandratsenka (subscriber, #50390) [Link]

Reading whole file in memory just to parse int from it's first line is very funny :)

You'll need a longer version like this

(File.open('foo.txt') {|f| f.readline}).to_i rescue deadParrot

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.