Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 70819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:47:27+00:00 2026-05-10T19:47:27+00:00

A class I am taking currently requires us to do all of our coding

  • 0

A class I am taking currently requires us to do all of our coding in smalltalk (it’s a Design class). On one of our projects, I am looking to do some things, and am having a tough time finding how to do them. It seems that what most people do is modify their own version of smalltalk to do what they need it to do. I am not at liberty to do this, as this would cause an error on my prof’s computer when he doesn’t have the same built-in methods I do.

Here’s what I’m looking to do:

Random Numbers. I need to create a random number between 1 and 1000. Right now I’m faking it by doing

rand := Random new. rand := (rand nextValue) * 1000. rand := rand asInteger. 

This gives me a number between 0 and 1000. Is there a way to do this in one command? similar to

Random between: 0 and: 1000 

And/Or statements. This one bugs the living daylights out of me. I have tried several different configurations of

(statement) and: (statement) ifTrue... (statement) and (statement) ifTrue... 

So I’m faking it with nested ifTrue statements:

(statement) ifTrue:[     (statement) ifTrue:[... 

What is the correct way to do and/or and Random in smalltalk?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:47:27+00:00Added an answer on May 10, 2026 at 7:47 pm

    The problem is that

     (expr) and: (expr) ifTrue: aBlock 

    is parsed as the method and:ifTrue: If you look at the Boolean class (and either True or False in particular), you notice that ifTrue: is just a regular method, and that no method and:ifTrue: exists – however, plain and: does. So to make it clear that these are two messages, write

    ((expr) and: (expr)) ifTrue: aBlock 

    For longer boolean combinations, notice that there are also methods and:and: and and:and:and: implemented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a blind student who's taking a required UI class. One of the assignments
I'm very new to Unix, and currently taking a class learning the basics of
I am taking a class in C++ programming and the professor told us that
Background: I am taking a class at my university called "Software Constraints". In the
I am taking a beginning C++ class, and would like to convert letters between
I'm a blind college student who is taking an introduction to programming class that
I'm trying to create a Quicksort base class using VB.NET, taking it an array
We have some client code which is using the SqlConnection class in .NET to
I'm taking an online java class and the teacher has asked for the following:
I'm currently taking over any links on the page that begin with users: $('a[href^=/users/]').live('click',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.