realbasic-nug
[Top] [All Lists]

Re: Dictionary lookup confuses me

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Dictionary lookup confuses me
From: Navdeep Bains <lists at bainsware dot com>
Date: Tue, 29 Apr 2008 21:05:23 -0700
Authentication-results: mx.google.com; spf=pass (google.com: domain of realbasic-nug-bounces at lists dot realsoftware dot com designates 66.116.103.65 as permitted sender) smtp dot mail=realbasic-nug-bounces at lists dot realsoftware dot com
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <59FCF004-8000-426D-BF76-3EAECBC61743 at macsos dot com dot au>
Hello,

Lookup doesn't return a boolean. If the key exists, it return the  
value associated with the key, otherwise it return the passed value.

Thanks,
Navdeep Bains
Bains Software

On Apr 29, 2008, at 8:56 PM, Gerard Hammond wrote:

> Hi All,
>
> I need to look into a dictionary just to see if a key exists.
>
> But the key seems to only exist if the value is an integer. 0 and
> doubles for the value cause the key to not be found by .lookup
>
> This sounds like a bug to me.
> What am I doing wrong?
>
>
>   dim n as new Dictionary
>   n.Value("thiskey") = 1 ' changing this to 0 leads to Nope, setting
> this to 1 leads to Yep, setting this to 1.2 leads to Nope - That is
> just weird...
>
>   if n.Lookup("thiskey", -1) Then
>     MsgBox "yep this key exists"
>   else
>     MsgBox "nope this key does not exists"
>   end if
>
>
> Cheers.
>
> --
>
> Dr Gerard Hammond
> Garvan Institute of Medical Research
>
>
>
> Cheers.
>
> --
>
> Dr Gerard Hammond
> http://www.macsos.com.au
>
> The Macintosh may only have 10% of the market, but it is clearly the
> top 10%.
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>