How can I generate random integers in a range in Smalltalk? -
a class taking requires of our coding in smalltalk (it's design class). on 1 of our projects, looking things, , having tough time finding how them. seems people modify own version of smalltalk need do. not @ liberty this, cause error on prof's computer when doesn't have same built-in methods do.
here's i'm looking do:
random numbers. need create random number between 1 , 1000. right i'm faking doing
rand := random new. rand := (rand nextvalue) * 1000. rand := rand asinteger.
this gives me number between 0 , 1000. there way in 1 command? similar
random between: 0 and: 1000
and/or statements. 1 bugs living daylights out of me. have tried several different configurations of
(statement) and: (statement) iftrue... (statement) , (statement) iftrue...
so i'm faking nested iftrue statements:
(statement) iftrue:[ (statement) iftrue:[...
what correct way and/or , random in smalltalk?
the problem that
(expr) and: (expr) iftrue: ablock
is parsed method and:iftrue:
if @ boolean class (and either true or false in particular), notice iftrue: regular method, , no method and:iftrue: exists - however, plain and: does. make clear these 2 messages, write
((expr) and: (expr)) iftrue: ablock
for longer boolean combinations, notice there methods and:and: , and:and:and: implemented.
Comments
Post a Comment