Max,

Am 16.07.2014 um 00:16 schrieb Verkoster Info <i...@derverkoster.de>:

> Hi,
> 
> I am using latest Pharo 3.0 + vm.
> 
> I have a method width with
> width
> 
>       ^ 115 * self ratio.
> in my understanding it returns a Number.
> 
> When I try to create a method
> negatedWidth
> 
>       ^   - (self width).
> 
> the UI tells me that only Numbers may be negated. I am not able to save the 
> method. Am I on a wrong path or should that work and if how can I avoid the 
> UI error message?
> 
It is all objects and you need to send a message to them in order to have a 
result. So a prefixed - (minus sign) won't work. But this is a very good 
demonstration what I have often encountered while learning smalltalk. The most 
obvious choice is the right one. The solution is already in the method name. 
You can write it

negatedWidth
   
   ^ self width negated 

:) You see. It is easy and it makes completely sense now, no?

Norbert



Reply via email to