[Q] Why we can't use - before a number?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Q] Why we can't use - before a number?

Edgar J. De Cleene
[Q] Why we can't use - before a number? To my previous question

mixedWith: aSoundBuffer
| start end |
start := - 32767 . “you can’t use it , Squeak is not FORTRAN , you should use 0 – aninteger instead “
end := 32767.
    ^ ((aSoundBuffer size >= self size) ifTrue: [aSoundBuffer] ifFalse: [self])
        collectWithIndex: [:s :i |    
            (s + (self at: i ifAbsent: [0])) forceIn: (Interval from: start to:  end)].

Edgar



Reply | Threaded
Open this post in threaded view
|

Re: [Q] Why we can't use - before a number?

Nicolas Cellier
2010/3/3 Edgar J. De Cleene <[hidden email]>:
> To my previous question
>
> mixedWith: aSoundBuffer
> | start end |
> start := - 32767 . “you can’t use it , Squeak is not FORTRAN , you should
> use 0 – aninteger instead “

Yes, we have no unary prefix operator,
But you can as well use -32767 without any space in between because
this is an officially supported Smalltalk literal.

Nicolas

> end := 32767.
>     ^ ((aSoundBuffer size >= self size) ifTrue: [aSoundBuffer] ifFalse:
> [self])
>         collectWithIndex: [:s :i |
>             (s + (self at: i ifAbsent: [0])) forceIn: (Interval from: start
> to:  end)].
>
> Edgar
>
>
>
>
>