----- Original Message -----
From: "Ron Jeffries" <ronjeffries / REMOVEacm.org.web-hosting.com>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>; <undisclosed-recipients:>
Sent: Sunday, March 03, 2002 10:36 AM
Subject: string to array and back


> I am needing to convert strings to arrays of bytes and back. I see pack
and
> unpack with argument of 'c*' will do it. Is there a better way?

I suggest you split on a null string. Won't this work?

    str = "ABC"
    arr = str.split("")   # ["A","B","C"]

As an aside: There is a kind of logic to the line-orientedness
of strings, esp. when you stop to think of a file as a single
multi-line string. I've gotten so used to it, it doesn't bother me
anymore.

Much the same with the byte vs. single-char-string situation.
I can't remember the rationale for it, though I've heard one. :)
And again, I've just gotten used to it.

Hal Fulton