Posted by
Pontus Östlund  -  September 2009
So what does this mean (a warning in Pike 7.8): Ranging object without index operator. The following code generates the warning:

if ((pos = search(q, "?")) > -1)
    q = q[pos+1..];
Posted by
Pontus Östlund  -  December 2009
No one?
Posted by
Martin Karlgren  -  December 2009
Do you expect "q" to be a string when it is in fact an object (without an index operator) perhaps? Try objectp(q) / stringp(q) to find out.
Posted by
Pontus Östlund  -  December 2009
Ah, soooo simple!

"q" is ambiguously declared and although it can't be anything but a string at this point in the code the Pike compiler can't know that.

So I swapped "q" to "string s = q" and did all computations on "s" instead and I got rid of the warning.

Many thanks :)
Posted by
Erik Dahl  -  December 2009
You could also use soft cast:

Which is telling the compiler that you know what you are doing. Usefull if you may need the ambigously declared variable.
Posted by
Pontus Östlund  -  December 2009
Haha, cool. I've always wondered what "[type]object" means in contrast to "(type)object".

I've fulfilled my motto today which is: Learn at least one new thing each day.
Search this thread: