[erlang-questions] jinterface List vs. String

Vlad Dumitrescu vladdu55@REDACTED
Tue Dec 9 12:52:19 CET 2008

> Maybe something like the following could be added to the OtpErlangString class?
>  /**
>   * Get this Erlang string as an Erlang list of Erlang bytes.
>   *
>   * @return the list of bytes contained in this string.
>   **/
>  public OtpErlangList asOtpErlangList() {
>    byte[] b = str.getBytes();
>    OtpErlangByte[] eb = new OtpErlangByte[b.length];
>    for (int i = 0; i < b.length; i++)
>      eb[i] = new OtpErlangByte(b[i]);
>    return new OtpErlangList(eb);
>  }

Yes, that would work. It is useful if you're going to keep your data
as OtpErlangObjects, if you're going to convert it to Java String or
List or whatever, then you can just as well do it directly.

> I haven't done Java in a while, maybe there's a way to "overload" the
> cast operator? That would be another way.

No, that isn't possible.


More information about the erlang-questions mailing list