I just got caught by at:ifAbsent: ...

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

I just got caught by at:ifAbsent: ...

Dennis smith-4
A bug was fixed between VW7.3.1 and VW7.4.1 in
ProcessEnvironment.

at: anId ifAbsent: [...]

would run the ... block (in VW7.3.1) if the value obtained was
either not-there OR "nil".  Somone had put code in our system which
set a specific value to "nil", then used
    at: ... ifAbsent: [...]
and it ran the ... code.

In VW7.4.1 this is "fixed".

OK -- to my thought.  There are many times where I say
    v := dict at: anId ifAbsent: [nil].
    ^v isNil ifTrue: [...] ifFalse: [v]

just because I know the value might have been set to nil and not
removed.  In fact there
are some cases where I want to hold the value open -- why? Saves some
GS/VW updates.

Anyway, has anyone ever thought of or added
    at: anId ifAbsentOrNil: [...]
for dictionaries??

--
Dennis Smith                        [hidden email]
Cherniak Software Development Corporation       +1 905.771.7011
400-10 Commerce Valley Dr E                Fax: +1 905.771.6288
Thornhill, ON Canada L3T 7N7    http://www.CherniakSoftware.com

Reply | Threaded
Open this post in threaded view
|

RE: I just got caught by at:ifAbsent: ...

Boris Popov, DeepCove Labs (SNN)
You could just do,

(dict at: #key ifAbsent: [nil]) ifNil: [Transcript show: 'nada']

Cheers,

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.

-----Original Message-----
From: Dennis Smith [mailto:[hidden email]]
Sent: Monday, October 16, 2006 12:11 PM
To: VWNC,
Subject: I just got caught by at:ifAbsent: ...

A bug was fixed between VW7.3.1 and VW7.4.1 in
ProcessEnvironment.

at: anId ifAbsent: [...]

would run the ... block (in VW7.3.1) if the value obtained was
either not-there OR "nil".  Somone had put code in our system which
set a specific value to "nil", then used
    at: ... ifAbsent: [...]
and it ran the ... code.

In VW7.4.1 this is "fixed".

OK -- to my thought.  There are many times where I say
    v := dict at: anId ifAbsent: [nil].
    ^v isNil ifTrue: [...] ifFalse: [v]

just because I know the value might have been set to nil and not
removed.  In fact there
are some cases where I want to hold the value open -- why? Saves some
GS/VW updates.

Anyway, has anyone ever thought of or added
    at: anId ifAbsentOrNil: [...]
for dictionaries??

--
Dennis Smith                        [hidden email]
Cherniak Software Development Corporation       +1 905.771.7011
400-10 Commerce Valley Dr E                Fax: +1 905.771.6288
Thornhill, ON Canada L3T 7N7    http://www.CherniakSoftware.com