writing my own method problem .
Hello, I have to make my own method but when I enter this: testShout self.assert: ( 'Do not panic' shout = "DO NO PANIC") The editor makes this : testShout self. Nothing more expected ->assert: ( 'Do not panic' shout = "DO NO PANIC") And I do not get a message that shout does not exist. Roelof
you are using a dot: self DOT assert: is wrong syntax. you need just a space: self assert: Esteban On 30 Mar 2014, at 11:26, Roelof Wobben <r.wobben@home.nl> wrote:
Hello,
I have to make my own method but when I enter this:
testShout self.assert: ( 'Do not panic' shout = "DO NO PANIC")
The editor makes this :
testShout self. Nothing more expected ->assert: ( 'Do not panic' shout = "DO NO PANIC")
And I do not get a message that shout does not exist.
Roelof
Esteban Lorenzano schreef op 30-3-2014 16:31:
you are using a dot:
self DOT assert: is wrong syntax.
you need just a space:
self assert:
Esteban
On 30 Mar 2014, at 11:26, Roelof Wobben <r.wobben@home.nl> wrote:
Hello,
I have to make my own method but when I enter this:
testShout self.assert: ( 'Do not panic' shout = "DO NO PANIC")
The editor makes this :
testShout self. Nothing more expected ->assert: ( 'Do not panic' shout = "DO NO PANIC")
And I do not get a message that shout does not exist.
Roelof
Thanks, it worked, Now a problem with the arrow above. According to the manual I have to type ^). But then I see the same error message as above. Roelof
Roelof Wobben wrote:
Esteban Lorenzano schreef op 30-3-2014 16:31:
you are using a dot:
self DOT assert: is wrong syntax.
you need just a space:
self assert:
Esteban
On 30 Mar 2014, at 11:26, Roelof Wobben <r.wobben@home.nl> wrote:
Hello,
I have to make my own method but when I enter this:
testShout self.assert: ( 'Do not panic' shout = "DO NO PANIC")
The editor makes this :
testShout self. Nothing more expected ->assert: ( 'Do not panic' shout = "DO NO PANIC")
And I do not get a message that shout does not exist.
Roelof
Thanks, it worked, Now a problem with the arrow above. According to the manual I have to type ^). But then I see the same error message as above.
Roelof
Happy to help* if you can give the whole line, or a page and a line number from PBE. Otherwise its shooting in the dark trying to guess what you need. cheers -ben *except I'm off to bed right now - but I'm sure that with that info someone else can chime in.
2014-03-30 15:26 GMT+01:00 Roelof Wobben <r.wobben@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
participants (4)
-
Ben Coman -
Esteban Lorenzano -
Roelof Wobben -
Sergi Reyner