Skip to content

Instantly share code, notes, and snippets.

Created April 17, 2014 18:28
Show Gist options
  • Save anonymous/11003152 to your computer and use it in GitHub Desktop.
Save anonymous/11003152 to your computer and use it in GitHub Desktop.
confusing behavior...
def pack(h)
tmpl = h.values.join('')
values = h.keys
return values.pack(tmpl)
end
p pack(
'S' => 'A1',
0 => 'L>',
'O' => 'A1') #=> "S\x00\x00\x00\x00O"
p pack(
'S' => 'A1',
0 => 'L>',
'S' => 'A1') #=> "S\x00\x00\x00\x00"
# (WHERE DID THE 'S' GO?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment