Ruby: Joining unpacked integers with strings

Posted: Saturday, 5 January 2013

If you're a novice at ruby like me, you've probably tried to join strings using plus signs when the data has been unpacked using .unpack():
no="1234"
no=no.unpack('N')
print "This number will not display: " + no
Typically the errors that you may see are:
can't convert Bignum into String
and
can't convert Array into String
So instead, bundle what you want to combine together in an array and use .join() to solve this issue...
no="1234"
no=no.unpack('N')
print ["This number will display: " , no].join("")