First time here? Check out the FAQ!

What's the best way to test for if a !HotVariable is within a specified range (i.e. between two fixed numbers)?

0 votes

After much searching, I found the following (on page 376)

between: minNumber and: maxNumber 

which looked promising .... but when I put in something like this:

!HotVariable between: 0.1 and: 0.2 

... hoping for a true/false answer, I get the error message that HotVariables cannot perform the operation between:and:

I'd also be in business if I could find a way to combine two tests into one true/false answer...

!HotVariable gt: 0.1 & lt: 0.2 

Surely there is a really easy and elegant way to do this.

asked Aug 17, 2018 in Capytalk & Smalltalk by mark-phillips (Practitioner) (860 points)

1 Answer

+2 votes
Between: and: is smalltalk, you need to use capytalk for realtime evaluation. How about: (!HotValue gt: 0.1) * (!HotValue lt: 0.2) Cheers, Gustav
answered Aug 17, 2018 by kymaguy (Virtuoso) (10,580 points)
edited Aug 17, 2018 by kymaguy
Btw for logical operations in general you can use * (multiply) for logical AND and + (add) for logical OR
Thanks ... this is an improvement on what I came up with before studying this:

(!HotVariable gt: 0.1) + (HotVariable lt: 0.2) eq: 2