Problems evaluating message sends in run-time arrays

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

Problems evaluating message sends in run-time arrays

Andy Burnett
I would like to create an array with a collection of colour values.

I tried both:

colorList := {Color blue}
and
colourList := {Color named: #blue.}.

In both cases it evaluates to 'Color blue' rather than the Color object.  

What surprised me was that:

charList := {Character digitValue:35. Character digitValue:33.}.

Does evaluate to an array of two characters.  What is going on?

Cheers
Andy
Reply | Threaded
Open this post in threaded view
|

Re: Problems evaluating message sends in run-time arrays

nacho
| colorList |
colorList := [ Color blue class ] value.

Lic. Ignacio Sniechowski, MBA
Prosavic SRL

Tel: (011) 4542-6714





















On Tue, Feb 10, 2015 at 10:38 PM, Andy Burnett <[hidden email]> wrote:
I would like to create an array with a collection of colour values.

I tried both:

colorList := {Color blue}
and
colourList := {Color named: #blue.}.

In both cases it evaluates to 'Color blue' rather than the Color object.  

What surprised me was that:

charList := {Character digitValue:35. Character digitValue:33.}.

Does evaluate to an array of two characters.  What is going on?

Cheers
Andy

Nacho Smalltalker apprentice. Buenos Aires, Argentina.
Reply | Threaded
Open this post in threaded view
|

Re: Problems evaluating message sends in run-time arrays

nacho
In reply to this post by Andy Burnett
or
| colorList |
colorList := { Color blue class }.

Lic. Ignacio Sniechowski, MBA
Prosavic SRL

Tel: (011) 4542-6714





















On Tue, Feb 10, 2015 at 10:38 PM, Andy Burnett <[hidden email]> wrote:
I would like to create an array with a collection of colour values.

I tried both:

colorList := {Color blue}
and
colourList := {Color named: #blue.}.

In both cases it evaluates to 'Color blue' rather than the Color object.  

What surprised me was that:

charList := {Character digitValue:35. Character digitValue:33.}.

Does evaluate to an array of two characters.  What is going on?

Cheers
Andy

Nacho Smalltalker apprentice. Buenos Aires, Argentina.
Reply | Threaded
Open this post in threaded view
|

Re: Problems evaluating message sends in run-time arrays

Sean P. DeNigris
Administrator
In reply to this post by Andy Burnett
Andy Burnett wrote
In both cases it evaluates to 'Color blue' rather than the Color object.
'Color blue' is the Color object you created and put in your array. It is aColor object. It's print string is 'Color blue'. See Color>>#printOn: for more info.

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Problems evaluating message sends in run-time arrays

Ben Coman
In reply to this post by Andy Burnett
I'm away from my Pharo computer to double-check, but is it just that is how a Color object displays itself ? Maybe have a look at Color>>printOn:
cheers -ben

On Wed, Feb 11, 2015 at 9:38 AM, Andy Burnett <[hidden email]> wrote:
I would like to create an array with a collection of colour values.

I tried both:

colorList := {Color blue}
and
colourList := {Color named: #blue.}.

In both cases it evaluates to 'Color blue' rather than the Color object.  

What surprised me was that:

charList := {Character digitValue:35. Character digitValue:33.}.

Does evaluate to an array of two characters.  What is going on?

Cheers
Andy

Reply | Threaded
Open this post in threaded view
|

Re: Problems evaluating message sends in run-time arrays

Andy Burnett
In reply to this post by Andy Burnett
Sean P. DeNigris wrote

<<<
Andy Burnett wrote
> In both cases it evaluates to 'Color blue' rather than the Color object.

'Color blue' is the Color object you created and put in your array. It is
aColor object. It's print string is 'Color blue'. See Color>>#printOn: for
more info.

>>>

Ah, of course! I completely misunderstood what the inspector was telling me.
Thanks very much
Reply | Threaded
Open this post in threaded view
|

Re: Problems evaluating message sends in run-time arrays

stepharo
In reply to this post by Andy Burnett

Le 11/2/15 02:38, Andy Burnett a écrit :
I would like to create an array with a collection of colour values.

I tried both:

colorList := {Color blue}
and
colourList := {Color named: #blue.}.

In both cases it evaluates to 'Color blue' rather than the Color object. 

Why do you rely on text when you can talk to objects?
Open an inspector and get the full power :)

What surprised me was that:

charList := {Character digitValue:35. Character digitValue:33.}.

Does evaluate to an array of two characters.  What is going on?

andy inspect the result and you will see that you get an array with two character.

Color blue
    print
    Color blue

because Color blue is a color which corresponds exactly to the result of sending the message blue to Color.

Some meta approach:
    Color blue hue

    Color blue intensity

if it replies to color message, it is a color.




Cheers
Andy