From: Joel VanderWerf Date: 2010-06-25T14:26:42+09:00 Subject: Re: writing binary file Ted Flethuseo wrote: > Hi everyone, > > I'm trying to write a couple of numbers to a binary file: > > num = [1234567, 30, 40] > File.open("test.file", "wb") { |f| > num.each { |e| f.write e.to_i.pack("I") } you gotta put the integers in an array. >> 3.pack "I" NoMethodError: undefined method `pack' for 3:Fixnum from (irb):1 >> [3].pack "I" => "\003\000\000\000" And use * for your num array: >> [1,2,3].pack "I*" => "\001\000\000\000\002\000\000\000\003\000\000\000"