I just went through the Ruby Doc. But there is no sufficient code to understand how the below three are used in Real life programming:
@
,X
,x
.
can anyone explain it with a simple snippet?
Thanks
I just went through the Ruby Doc. But there is no sufficient code to understand how the below three are used in Real life programming:
@
,X
,x
.
can anyone explain it with a simple snippet?
Thanks
I will give you few example and will be learning together with you:
So serializes in unsigned chars. Every letter in new byte.
Think of the 'X' as backspace directive
'x' places zero valued byte.
'@' seems to be a single backspace, but will not support multiple operations at one time. The last one as explanation does not relate at all with the text from the documentation:
But is what it seems to be doing.
EDIT BTW
@
seems a lot more logical when looked in the context ofunpack
:Starts unpacking from the very beginning once more.
EDIT2 And here goes the explanation of the other two directives in the context of unpacking:
So 'x' ignores the next to decode byte and 'X' will make the previous byte the next to read once more. 'X' can stack.
Here goes my first attempt of summarizing the results:
pack
:unpack
:NOTE Reader is a word I made up for ease of explanation and is, by no means, formal.
EDIT3 Here goes the explanation of "\x01" notation too:
It seems like this stands for hexadecimal representation. And all the site I have linked to use decimal representation apparently. Otherwise, as it can be seen those are the hexadecimal representations of the given numbers.