Alwin Blok wrote: > Hello! > > I'm new to ruby. I'm learning it and it seems to be a very nice language. > > However, I do have a question about binary handling. I'd like to write > binary data directly to a file. > I found that I can use myfile.write(["1001010100"].pack("B10")), but i'd > like to be able to write, for example 0b1001010100 directly to a file. > How do I do that, or else, are ther other useful ways to write binary > data to a file > > Thanks in advance > > Alwin > very old coding style, may be of interest begin out_file = your data f = File.new("file name", "w") end begin out_file.each{ |ch| f.binmode.putc(ch) } ensure f.close end neil