- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Re: String.toCharArray behaving weirdly
Fri, 2011-03-25, 12:07
That doesn't address the question. res0 is a java.lang.String. It
prints in the REPL as "O$", but that's not its value; it's value is
actually "line0$object$$iw$$iw$O$" -- this can be confirmed by noting
that res0.length returns 23, res0(0) returns 'l', etc., or just by
printing it:
scala> println(res0)
line0$object$$iw$$iw$O$
And it's the value itself that gets this treatment; e.g.,
scala> val x = "line0$object$$iw$$iw$O$"
x: java.lang.String = O$
OTOH,
scala> val x = "ine0$object$$iw$$iw$O$"
x: java.lang.String = ine0$object$O$
That's pretty weird -- perhaps the REPL magician can explain this magic.