[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] unexpected #indexOf:ifAbsent: result (was What am I

From: Stephen Compall
Subject: Re: [Help-smalltalk] unexpected #indexOf:ifAbsent: result (was What am I doing wrong here?)
Date: Mon, 11 Sep 2006 14:33:22 -0500
User-agent: Thunderbird (Macintosh/20060719)

Bram Neijt wrote:
> The following puzzles me (in gst):
> st> 'a/b' indexOf: '/' ifAbsent: ['ABSENT' printNl]!

Here is the doc for (String whichClassIncludesSelector:
#indexOf:ifAbsent:) >> #indexOf:ifAbsent:

indexOf: anElement ifAbsent: exceptionBlock
     Answer the index of the first occurrence of anElement in the
     receiver.  Invoke exceptionBlock and answer its result if no item
     is found

Now, ask yourself, what does "anElement" mean in the context of
Strings?  Hint: the element '/' is in fact *not* present in the String
'a/b'.  Also look around SequenceableCollection's 'basic' methods for
the method that does what you expect here.

Stephen Compall

reply via email to

[Prev in Thread] Current Thread [Next in Thread]