Bug with string methods? [message #89846] |
Wed, 10 December 2014 14:31  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
Am I misunderstanding the documentation, or is there a bug with some string methods?
When a string has more than one character, substring() works as I expected, from the documentation:
IDL> str='ab'
IDL> print,str.substring(-1)
b
But if the string has length 1, I get an empty string:
IDL> str='a'
IDL> print,str.substring(-1)
IDL> print,strlen(str.substring(-1))
0
IDL>
A similar problem happens with remove():
IDL> str='ab'
IDL> print,str.remove(-1)
a
IDL> str='a'
IDL> print,str.remove(-1)
a
|
|
|
Re: Bug with string methods? [message #89850 is a reply to message #89846] |
Wed, 10 December 2014 16:02  |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Wednesday, December 10, 2014 3:31:21 PM UTC-7, Paulo Penteado wrote:
> Am I misunderstanding the documentation, or is there a bug with some string methods?
>
> When a string has more than one character, substring() works as I expected, from the documentation:
>
> IDL> str='ab'
> IDL> print,str.substring(-1)
> b
>
> But if the string has length 1, I get an empty string:
>
> IDL> str='a'
> IDL> print,str.substring(-1)
>
> IDL> print,strlen(str.substring(-1))
> 0
> IDL>
>
> A similar problem happens with remove():
>
> IDL> str='ab'
> IDL> print,str.remove(-1)
> a
> IDL> str='a'
> IDL> print,str.remove(-1)
> a
Drats, that looks like a bug. Good catch Paulo. I'll try to slip it into the next patch release.
-Chris
|
|
|