[Pharo-users] writing my own method problem .

Sergi Reyner sergi.reyner at gmail.com
Sun Mar 30 12:10:41 EDT 2014


2014-03-30 15:26 GMT+01:00 Roelof Wobben <r.wobben at home.nl>:

> testShout
>   self. Nothing more expected ->assert: ( 'Do not panic' shout = "DO NO
> PANIC")
>

There are some things wrong with the second line:

   - there´s a period after self, you must remove it
   - you wrote NO instead of NOT, so the the assert will fail
   - the sentence in capitals is surrounded by double quotes $" which are
   for comments; strings are surrounded by single quotes $' , this makes your
   code actually be:

( 'Do not panic' shout = )



To write the return operator, ^, I can use one of these two combinations in
my linux box (which has a slightly weird US international keyboard layout):

   - press shift+6 twice
   - press shift+6, then press space


As an additional note, you don´t actually need the parentheses there,
because the order of evaluation is:

   - unary messages (#shout)
   - binary messages (#=)
   - keyword messages (#assert:)

So you can write:

testShout

^ self assert: 'do not panic' shout = 'DO NOT PANIC'



Hope this helps in getting a better grasp of Smalltalk syntax. I found it
really easy and fun to learn :)

Cheers,
Sergi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20140330/a63c862d/attachment.html>


More information about the Pharo-users mailing list