[Newbies] Total newb...

Tony Giaccone tony at giaccone.org
Tue Oct 14 06:11:49 UTC 2008


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




More information about the Beginners mailing list