Given the sort of questions you’ve been posting, I have to ask. Are you
familiar with www.google.com ?
Yes, I know. but one thing none of the docs I found have an
explanation,why the output is coming,what the logic behind it.Thus I
pasted here,hoping that people who worked long in this platform might
have practical experience on this,can give me the logic with
explanation. I have Google also but my bad i didn’t get any of such
where has some keen explanations.
Why are the results reversed? They’re not, you typed them in one
order the first time and the other the second.
Why does the bang version return nil? As the docs
(Class: Array (Ruby 1.9.3)) say,
“Returns nil if no changes are made (that is, no duplicates are
found).” Of course in [] there will be no dups.
Why IS there a difference? Generally, when there are both bang and
normal versions of a method, the bang version affects the object
passed in, while the normal version acts on (and returns) a duplicate.
In the bang case, you usually don’t care about the return value, and
are using it instead for the effect on the receiver.
Why do fools fall in love? Why do birds sing? Why is this night
different from all other nights? Why ask why, drink Bud Dry!
What bad with you? why you posted your question with me? its not your
post! Create your new post then put the question. Just clean my post.
This is not your post, your question is conflicting with mine!
Open your eyes and see where you posted your question! BAD
have practical experience on this,can give me the logic with
explanation. I have Google also but my bad i didn’t get any of such
where has some keen explanations.
On Sun, Jan 13, 2013 at 3:36 AM, tamouse mailing lists [email protected] wrote:
pasted here,hoping that people who worked long in this platform might
have practical experience on this,can give me the logic with
explanation. I have Google also but my bad i didn’t get any of such
where has some keen explanations.
Maybe you should read the code?
I’d start with the documentation and if something is not clear ask
/specific/ questions.
Unpack decodes a string based on the format you specify and returns an
array of the decoded elements. The format specifier is made up of a
single character and may be followed by a number indicating how many
times to repeat the format specifier, or a ‘*’ to indicate all remaining
elements. In the examples you provided:
‘A’.unpack(‘b*’)
Will return a string representation of the binary value of ‘A’ in LSB
first order.
‘A’.unpack(‘B*’)
Will return a string representation of the binary value of ‘A’ in MSB
first order.
“hello”.unpack(‘B*’)
This returns a string representation of the binary values ‘h’, ‘e’, ‘l’,
‘l’, ‘o’ in MSB first order
“hello”.unpack(‘C*’).map { |e| e.to_s 2 }
Unpack creates an array of the integer values of ‘h’, ‘e’, ‘l’, ‘l’,
‘o’. This is then iterated over to create a new array by converting each
value to a string using Base2 or binary format.
Unpack decodes a string based on the format you specify and returns an
array of the decoded elements. The format specifier is made up of a
single character and may be followed by a number indicating how many
times to repeat the format specifier, or a ‘*’ to indicate all remaining
elements. In the examples you provided:
‘A’.unpack(‘b*’)
Will return a string representation of the binary value of ‘A’ in LSB
first order.
Unpack decodes a string based on the format you specify and returns an
array of the decoded elements. The format specifier is made up of a
single character and may be followed by a number indicating how many
times to repeat the format specifier, or ‘*’ to indicate all remaining
elements. In the examples you provided:
Thanks for clearing this up for me. My thoughts were mixed up on this
one as well.