[Newbies] Quick noob snippets

Sven Schott sven.schott at gmail.com
Tue May 20 03:30:47 UTC 2008


Hi all

Just a quick couple of questions (nothing serious).


I was going through the SBE and came up on OrderedCollections. I tried the
following:


c := OrderedCollection newFrom: { 1. 5. 8. 45. 23. 3. 20 }.
String newFrom: c


but I get the following: 'Error: Improper store into indexable object'. What
I was expecting was:


1584523320 (because in Ruby world I can do something like this:)


irb(main):001:0> [1,2,3,4,5,6,7,8].to_s
=> "12345678"
irb(main):002:0>


I was at least expecting something weird but not an error.


I eventually figured that it was because I was using Ints instead of
Characters because this works fine:


str := OrderedCollection newFrom: { $a. $g. $t. $e }.
str as: String


So, the question is why do I get the error? Shouldn't String be able to
convert any object into a String representation? In Rubylandwhere that's all
fair game but I get the feeling that you can't just do that since it is
String doing the conversion by (possibly) sending a message that
OrderedCollection does not support. If that's the case, how do you do it?


The second question is kinda stupid. I was playing around with the browser
in Squeak (I had just learned how to open Morphs in the World. Yay!) and
tried this:


anEllipse := EllipseMorph new.
anEllipse defaultColor.
anEllipse openInWorld


anEllipse color: Color red
anEllipse borderWidth: 10
anEllipse height: 100
100 timesRepeat: [randomNo := 100 atRandom. anEllipse height: randomNo.
anEllipse borderWidth: anEllipse borderWidth + 1 ]


It did work but it did the moves all at once. At first I thought that it was
just doing it so quick I couldn't see but I increased the number of
iterations but all that did was hang the UI for a sec or so and then leave
the ellipse at a random location (as expected). I guess I was trying to
animate it but the UI doesn't update. Is it a block thing? That is, is it
that the block is evaluated and then the UI is updated? Just curious. I'm
probably trying to do this in a rather silly way.


Anyhoo, that's it. I'm loving it so far and I've ordered the Seaside book
from Lulu. Even if I don't ever get to use this officially in my work, I'm
glad I found it because I will now be able to write tools very quickly and
easily AND move them between platforms with a quick scp or anything else for
that matter..


Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080520/d09f4af1/attachment.htm


More information about the Beginners mailing list