Reputation: 24623
I am trying to understand smalltalk and trying following simple code with gnu-smalltalk:
Object subclass: Myclass[
myMethod: val [val printNl]
]
mc := Myclass new.
mc myMethod: "55".
However, it does not work and gives following error:
$gst simpleclass.st
simpleclass.st:6: expected object
I thought "55"
is an object in smalltalk.
Obviously I am missing something very basic but I am not able to figure it out. Thanks for your help.
Upvotes: 0
Views: 83
Reputation: 14843
The reason why
mc := Myclass new.
mc myMethod: "55".
doesn't work is simple: In Smalltalk double quoted strings are comments. Hence, for the compiler, your expression is equivalent to:
mc myMethod:
as if there was no argument whatsoever. The intended expression should have been
mc myMethod: 55 "and now this should work!"
Upvotes: 2