Ian Bicking: the old part of his blog

Theunbridledhumanityofapiscomment000

source
// "stupid" seems an appropriate description for a language that can't split a string...
// To be honest, I can't figure out how they screwed this up.  I'm trying 
// to imagine what the underlying split() code looks like, and I can't picture it.
public class stupid
{
    public static void main (String[] args)
    {
        System.out.println("1:2:3".split(":").length);
        System.out.println(":2:3".split(":").length);
        System.out.println("1:2:".split(":").length);
        System.out.println(":2:".split(":").length);
        System.out.println("1::".split(":").length);
        System.out.println("::".split(":").length);
    }
}

C:\tmp>javac stupid.java && java -cp . stupid
3
3
2
2
1
0

Compare:
>>> print len("1:2:3".split(":"))
3
>>> print len("1:2:".split(":"))
3
>>> print len(":2:".split(":"))
3
>>> print len("::".split(":"))
3
Comment on Re: The unbridled humanity of APIs
by msw