comparison in a variable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

comparison in a variable

Joseph Alotta
Greetings,

I am trying to store a test condition in a variable:

| test |

test := '>'.

( 5 test 7)  ==> false


I tried:

test := $>.

test := [ :x :y |  x > y ].


How is this done?


Thank you for your help.


Sincerely,

Joe.



Reply | Threaded
Open this post in threaded view
|

Re: comparison in a variable

douglas mcpherson

On Nov 7, 2012, at 10:02 , Joseph J Alotta wrote:

> Greetings,
>
> I am trying to store a test condition in a variable:
>
> | test |
>
> test := '>'.
>
> ( 5 test 7)  ==> false
>
>
> I tried:
>
> test := $>.

For this style you could say
test := #>.
5 perform: test withArguments: #(7)


>
> test := [ :x :y |  x > y ].
>

Or using a block you could say:
test := [:x :y | x > y].
test value: 5 value: 7

HTH

>
> How is this done?
>
>
> Thank you for your help.
>
>
> Sincerely,
>
> Joe.
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: comparison in a variable

Bob Arning-2
In reply to this post by Joseph Alotta
test := [ :x :y |  x > y ].

test value: 5 value: 7 ==> false

or

test := #>

5 perform: test with: 7

Cheers,
Bob

On 11/7/12 1:02 PM, Joseph J Alotta wrote:

> Greetings,
>
> I am trying to store a test condition in a variable:
>
> | test |
>
> test := '>'.
>
> ( 5 test 7)  ==> false
>
>
> I tried:
>
> test := $>.
>
> test := [ :x :y |  x > y ].
>
>
> How is this done?
>
>
> Thank you for your help.
>
>
> Sincerely,
>
> Joe.
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: comparison in a variable

Bert Freudenberg
In reply to this post by Joseph Alotta
Hi Joe,

please use our beginner's list for beginner's questions:

        http://lists.squeak.org/mailman/listinfo/beginners

People are friendly here, too, but if you post over there, other beginners can learn from your posts and the answers, too.

- Bert -

On 2012-11-07, at 19:02, Joseph J Alotta <[hidden email]> wrote:

> Greetings,
>
> I am trying to store a test condition in a variable:
>
> | test |
>
> test := '>'.
>
> ( 5 test 7)  ==> false
>
>
> I tried:
>
> test := $>.
>
> test := [ :x :y |  x > y ].
>
>
> How is this done?
>
>
> Thank you for your help.
>
>
> Sincerely,
>
> Joe.