When running indexOf on a list of Gstrings, the return value is always -1 despite an expected index match:
mystr = "foo"
// expect .indexOf to return 0
println "${["${mystr}_bar", "baz"].indexOf("foo_bar")}" // -1
println "${[mystr + "_bar", "baz"].indexOf("foo_bar")}" // 0
Am I misunderstanding something or is this a bug?
You would have to use:
(note the explicit
.toString()there).GStringlook the same (e.g. they.toString()to their current state) likeString, but they aren't. E.g. you can have a closure inside aGStringor a call to generate a random number. They are not immutable or "stable" like theirStringbrothers. That e.g. is also the reason, why they are unfit to be keys in maps. So they equal the same, but they hash different.