Created
April 17, 2014 18:28
-
-
Save anonymous/11003152 to your computer and use it in GitHub Desktop.
confusing behavior...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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