4 ms·
Tried: a := TextWindow new: 'a test'. a moveX:200 Y: 200. It worked. Nice. Tried to add a factorial instance method to the Number class: factorial
by cesare 17y ago
Tried:
a := TextWindow new: 'a test'.
a moveX:200 Y: 200.
It worked. Nice.
Tried to add a factorial instance method to the Number class:
factorial
"comments"
self = 0 ifTrue: [^ 1].
self > 0 ifTrue: [^ self * (self - 1) factorial].
Then in Workspace:
Transcript show: 10 factorial.
prints: 10 does not understand factorial.
Anyway, it looks promising.
- shaunxcode 17y agoNo luck for me either. I added factorial, saved, saved, image, loaded image (it shows factorial in transcript being loaded). Try it out in workspace and nothing. It was interesting to "show it" on an anonymous block and see the javascript function it is creating: [:x | (x + 1) + x]. function (thisObject, x) { x['perform:with:']("+", 1)['perform:with:']("+", x); }