[Newbies] Total newb...
Matthias Berth
matthias.berth at googlemail.com
Tue Oct 14 06:28:25 UTC 2008
Hi Tony,
welcome to Smalltalk :-) Try this:
s := 'abcdef' asSet.
s includes: $a.
To see similar methods, browse the class Collection - in the testing category.
HTH
Matthias
On Tue, Oct 14, 2008 at 8:11 AM, Tony Giaccone <tony at giaccone.org> wrote:
> Ok, so I'm really new to smalltalk. I've done a few basic tutorials and have
> a simple understanding of the syntax. My pervious programing experience is
> mostly java/C with a bit of Objective C in the mix.
>
> I'm trying to figure out how to do what seems like a simple thing.
>
> I have a set, I'd like to find out if an object exists in the set.
>
> In a general form. Let's use the a relatively simple case.
>
> Assume I have classes Rock Paper and Scissors.
>
>
> validHands := Set new.
> validHands add: Rock new; add Paper new; add Scissors new.
>
> Assume I have a player object which responds to the method throwsAHand with
> an instance of Rock Paper or Scissors.
>
> how do I craft
>
> validHands contains: aPlayer throwsAHand
>
> I know that contains: takes a block, and that this isn't correctly done..
> but I'm trying to get the a handle on how to do this.
> The intent is to return a boolean, that indicates if the object the player
> threw is in the Set of valid objects that can be thrown.
>
>
> Tony
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list