From tlwilkinsonyyc at gmail.com Wed Mar 2 05:34:36 2011 From: tlwilkinsonyyc at gmail.com (Tom Wilkinson) Date: Tue, 1 Mar 2011 21:34:36 -0700 Subject: [sbe-discussion] Problem with the Code Message-ID: I am very new to this and am not sure if this is where I should be putting this but I was starting to work through the Pharo by Example and had Grabbed Version 2009-10-28 and was working through the first example which is below. This code when I was trying to accept it gave the following message below. I have verified it was entered as per the book. As you can see in the first line of the method it is looking for a right bracket. As I am just starting to learn smalltalk I have no idea why this is not working. Any idea on why the code from the book does not work or how to fix this so I can continue. regards It is a great book. Organizing methods into protocols 39 Add the methodsLOGame?cellsPerSideandLOGame?newCellAt:at:. Con?rm the spelling of the new selectorstoggleNeighboursOfCellAt:at:and mouseAction:. Method 2.6 answers a new LOCell, specialized to position(i, j)in the Matrixof cells. The last line de?nes the new cell?smouseActionto be the block[self toggleNeighboursOfCellAt: i at: j ].In effect, this de?nes the callback be- haviour to perform when the mouse is clicked. The corresponding method also needs to be de?ned. Method 2.7:The callback method toggleNeighboursOfCellAt: i at: j (i > 1) ifTrue: [ (cells at: i ? right parenthesis expected ->1 at: j ) toggleState]. (i < self cellsPerSide) ifTrue: [ (cells at: i + 1 at: j) toggleState]. (j > 1) ifTrue: [ (cells at: i at: j ? 1) toggleState]. (j < self cellsPerSide) ifTrue: [ (cells at: i at: j + 1) toggleState]. -- Tom Wilkinson Sent with Sparrow -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar at iam.unibe.ch Wed Mar 2 08:53:20 2011 From: oscar at iam.unibe.ch (Oscar Nierstrasz) Date: Wed, 2 Mar 2011 08:53:20 +0100 Subject: [sbe-discussion] Re: Problem with the Code In-Reply-To: References: Message-ID: Hi Tom, Thanks for pointing this out. It looks like you tried to copy and paste the code from the PDF. That won't work because what looks like a minus sign just before the error is actually an em-dash in the PDF. Unfortunately Pharo does not know what an em-dash is, so it gets confused. If you want to copy-paste code, please grab them from this file in the github repo for the book: https://github.com/SquareBracketAssociates/PharoByExample-english/blob/master/pbe1-examples.txt I have now added a link to the PBE home page under Resources. Cheers, - on On 2 Mar 2011, at 05:34, Tom Wilkinson wrote: > > I am very new to this and am not sure if this is where I should be putting this but I was starting to work through the Pharo by Example and had Grabbed Version 2009-10-28 and was working through the first example which is below. This code when I was trying to accept it gave the following message below. I have verified it was entered as per the book. As you can see in the first line of the method it is looking for a right bracket. As I am just starting to learn smalltalk I have no idea why this is not working. > > Any idea on why the code from the book does not work or how to fix this so I can continue. > > regards > > It is a great book. > > Organizing methods into protocols 39 > Add the methodsLOGame?cellsPerSideandLOGame?newCellAt:at:. > Con?rm the spelling of the new selectorstoggleNeighboursOfCellAt:at:and > mouseAction:. > Method 2.6 answers a new LOCell, specialized to position(i, j)in the > Matrixof cells. The last line de?nes the new cell?smouseActionto be the > block[self toggleNeighboursOfCellAt: i at: j ].In effect, this de?nes the callback be- > haviour to perform when the mouse is clicked. The corresponding method > also needs to be de?ned. > Method 2.7:The callback method > > toggleNeighboursOfCellAt: i at: j > (i > 1) ifTrue: [ (cells at: i ? right parenthesis expected ->1 at: j ) toggleState]. > (i < self cellsPerSide) ifTrue: [ (cells at: i + 1 at: j) toggleState]. > (j > 1) ifTrue: [ (cells at: i at: j ? 1) toggleState]. > (j < self cellsPerSide) ifTrue: [ (cells at: i at: j + 1) toggleState]. > > -- > Tom Wilkinson > Sent with Sparrow > _______________________________________________ > Sbe-discussion mailing list > Sbe-discussion at iam.unibe.ch > https://www.iam.unibe.ch/mailman/listinfo/sbe-discussion