Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!cernvax!chx400!chx400!hslrswi!naz From: naz@hslrswi.hasler.ascom.ch (Norman H. Azadian) Newsgroups: comp.lang.icon Subject: string indexing peculiarity Keywords: string indexing Message-ID: <1871@hslrswi.hasler.ascom.ch> Date: 26 Feb 91 08:26:10 GMT Organization: Hasler AG Lines: 24 Recently I found out the hard way about something I consider to be an anomaly in string indexing. I consider it an anomaly because it was, at least for me, totally unexpected. To wit: s := "-D" x := (s[3:0] | "default") "Obviously" accessing the 3rd character in a 2-character string should fail and x would get the string "default". It turns out, non-intuitively enough, that I get an empty string, exactly as if I had tried s[1:1]. Thinking about it, I have to admit that it makes a certain amount of sense. In fact, it makes a lot of sense when I think about it. However it was totally unexpected and so I thought I'd mention it to perhaps help some other hapless soul from falling into the same pit. NHA -- PAPER: Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland INTERNET: naz%hslrswi.uucp@uunet.uu.net UUCP: ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz VOICE: +41 31 63 2178 BITNET: naz%hslrswi.UUCP@cernvax.BITNET